Home End User

Blank PDF when saving from ppViewer

edited January 2009 in End User
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

Comments

  • edited January 2009
    Hi Stian,

    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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2009
    Sorry, no change. Got the same error after changing the devicetype. Any more
    ideas?
    Many thanks for the help.


  • edited January 2009
    Hi Stian,

    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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2009
    Sorry, still no change. Can redefine the problem. The PDF is not "blank",
    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.



  • edited January 2009
    Hi Stian,

    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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2009
    I think I have found the problem, and it seems like the problems is not
    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

  • edited January 2009
    Hello again,

    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



  • edited January 2009
    Hi 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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.