Blank PDF when saving from ppViewer
Our application has a ppViewer (TppViewer) on a form used for previewing
reports. We have added the options for saving this report to .PDF, but the
created PDF-file is blank (Acrobat Reader displays error message that says
there is no pages in this document). Can mention that the reports is shown
perfectly in the ppViewer before printing to PDF.
- The code for the savebutton:
with ppViewer.Report do
begin
AllowPrintToFile := True;
ShowPrintDialog := False;
DeviceType := dtPDF;
TextFileName := strFilename;
PDFSettings.Author := 'Navi';
PDFSettings.Title := 'Export to PDF!';
PDFSettings.OpenPDFFile := True;
Print;
end;
- The object source from .pas:
object ppViewer: TppViewer
Left = 0
Top = 27
Width = 619
Height = 374
Cursor = crHandPoint
Align = alClient
BevelOuter = bvNone
Color = clBtnShadow
PageColor = clWindow
ZoomPercentage = 100
ZoomSetting = zsWholePage
OnClick = ppViewerClick
OnPageChange = ppViewerPageChange
end
reports. We have added the options for saving this report to .PDF, but the
created PDF-file is blank (Acrobat Reader displays error message that says
there is no pages in this document). Can mention that the reports is shown
perfectly in the ppViewer before printing to PDF.
- The code for the savebutton:
with ppViewer.Report do
begin
AllowPrintToFile := True;
ShowPrintDialog := False;
DeviceType := dtPDF;
TextFileName := strFilename;
PDFSettings.Author := 'Navi';
PDFSettings.Title := 'Export to PDF!';
PDFSettings.OpenPDFFile := True;
Print;
end;
- The object source from .pas:
object ppViewer: TppViewer
Left = 0
Top = 27
Width = 619
Height = 374
Cursor = crHandPoint
Align = alClient
BevelOuter = bvNone
Color = clBtnShadow
PageColor = clWindow
ZoomPercentage = 100
ZoomSetting = zsWholePage
OnClick = ppViewerClick
OnPageChange = ppViewerPageChange
end
This discussion has been closed.
Comments
The DeviceType property expects a string value. Try setting it to 'PDF' and
see if that helps.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
ideas?
Many thanks for the help.
I just noticed that you are using the TppViewer.Report property to access
the report. This is a TppProducer class which is an ancestor to the
TppReport class. Try typecasting TppViewer.Report as a TppReport.
with TppReport(ppViewer.Report) do
...
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
but has no pages. The excate error message Acrobat Reader displays is "There
was an error opening this document. This file cannot be opened because it
has no pages.". I don't need any other components from DM on the form for
print to PDF to work right? On this form I only got a "save to pdf"-button
and the TppViewer. The viewer displays the report corretly, but the pdf
remains blank.
This is not a known issue. In my testing with your exact code posted, I am
able to successfully export to a PDF file.
Which version of ReportBuilder and Delphi are you using? If possible,
please send a simple/minimal example demonstrating the issue to
support@digital-metaphors.com in .zip format and I'll take a look at it for
you.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
related to ReportBuilder. When stepping through all my code on the report
project, I found that the function that finds the active report component
(FindComponent) returns blank. The reason we have this function is because
we have the report components for each report of our system on a indivisual
form (frmRep1, frmRep2, frmRep3 a.s.o). When trying to add a test component
(ppReport) to my preview form where ppViewer is located, the PDF is created
perfectly. Sorry for the trouble, and thanks for the help.
Regards,
Stian Ertvaag
Waade Information System AS
NO-Norway
Is there a known problem when the ppReport and ppViewer are not located on
the same form? Our ppReport is on a form created on the OnCreate on the form
for the ppViewer, and the ppViewer.Report is connected to the other forms
ppReport.
Regards,
Stian
This should not be an issue. I performed a quick test and created a simple
app similar to what you describe below and the report exported to PDF
successfully. Is there something else you can tell me about your
environment that may be causing this?
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com