Home General

Merging to Reports into one PDF - Second Report Sometimes Has No Data - PDF Erased

edited November 2010 in General
Using the technique described in this article:

http://www.digital-metaphors.com:8080/Output/PDF/How_To...Merge_Multiple_Reports_into_one_PDF

I find that on the occasions when the 2nd report has no data, the entire PDF
is erased when it attempts to generate the 2nd report.

I am setting the NoDataBehaviors for the report to [ndBlankPage].

Is there something else I am missing? Is there an easy way to get the PDF to
retain the contents of the first report when the 2nd has no data?

Thanks,

Steve Elliott

Comments

  • edited November 2010
    Hi Steve,

    If you have the NoDataBehaviors set to BlankPage, you should still get a
    page when exporting a report regardless the data provided. In my testing
    with the example you mentioned below, I reconfigured the second report to an
    empty report and exported to PDF. This gave me a merged PDF which included
    the first report and a blank page for the second. Are you able to alter the
    example to demonstrate what is happening to your app? If so, please give me
    the steps I can take 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 November 2010
    Nico,

    Making up an example report would take me some time, so I did a little
    debugging and code browsing first.

    If I set the the NoDatabehaviors to [ndBlankReport], then the PDF file is
    not deleted. However, I really do not want an unpopulated report page if
    there is not data for the 2nd report.

    Also, I see this little block of code in ppReport.pas:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    {cancel the job if no page was sent to the device}
    if DonePrinting and (AbsolutePageCount = 0) and (ndBlankPage in
    NoDataBehaviors) then
    begin
    Cancel;
    // Reset;
    end;
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    I may be reading this wrong, but this would seem to indicate if printing is
    complete, with no pages, and ndBlankPage is in the NoDatabehaviors, then it
    calls the Cancel routine - which in the case of the PDF device - deletes the
    file.

    Am I reading this correctly?

    Steve Elliott

  • edited November 2010
    OK. I replicated the issue using the example and actually linking the 2nd
    report to data.

    1) I downloaded the example MultipleReportsAsOnePDF.zip

    2) Modified ppReport 2 to actually pull data from a database - using the
    report designer on ppReport2 I did a file, new, added the animals table with
    all defaults,

    3) Right clicked on the animals table displayed in the Data tab, did a
    preview to show all records.

    4) Switched to the design tab, added a dbtext field linked to the Name field
    in the detail section.

    5) Saved, compiled, all worked as expected. PDF file produced.

    6) Went back into the ppReport2 in the designer, on the data tab, right
    clicked on the animals table and selected search, added a criteria of size =
    200 (no records in the table have this size).

    7) Saved, compiled, executed. No PDF.

    8) If I step through the program in the Delphi debugger I see the PDF get
    created after the ppReport1.PrintToDevices call.

    9) If I step through the rest of the code after ppReport2.PrintToDevices is
    called, the PDF is deleted.

    Steve

  • edited November 2010
    Hi Steve,

    Thanks, there is now a patch available for RB 12.02 that addresses this
    issue. Please contact support@digital-metaphors.com if you would like the
    patch.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    "Steve Elliott" wrote in message news:4cdabf55$1@mail....

    OK. I replicated the issue using the example and actually linking the 2nd
    report to data.

    1) I downloaded the example MultipleReportsAsOnePDF.zip

    2) Modified ppReport 2 to actually pull data from a database - using the
    report designer on ppReport2 I did a file, new, added the animals table with
    all defaults,

    3) Right clicked on the animals table displayed in the Data tab, did a
    preview to show all records.

    4) Switched to the design tab, added a dbtext field linked to the Name field
    in the detail section.

    5) Saved, compiled, all worked as expected. PDF file produced.

    6) Went back into the ppReport2 in the designer, on the data tab, right
    clicked on the animals table and selected search, added a criteria of size =
    200 (no records in the table have this size).

    7) Saved, compiled, executed. No PDF.

    8) If I step through the program in the Delphi debugger I see the PDF get
    created after the ppReport1.PrintToDevices call.

    9) If I step through the rest of the code after ppReport2.PrintToDevices is
    called, the PDF is deleted.

    Steve

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2010
    Thank you. I will be applying the patch later today.

  • edited November 2010
    Nico,

    That works!

    Thanks,

    Steve Elliott

This discussion has been closed.