Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

PDF Empty after print

edited February 2011 in General
Hello,

I'am having problems creating an PDF file.

when i'm running this code:

TextEditor.LoadFromFile(RTFTemplate);
TextEditor.MailMerge := True;
Report.TextFileName := RTFOutputFile;
Report.DeviceType := dtDoc;
Report.Print;

I'll get an doc-file which shows an merged RTF file, everything is fine.

When running this code:

TextEditor.LoadFromFile(RTFTemplate);
TextEditor.MailMerge := True;
Report.TextFileName := PDFOutputFile;
Report.DeviceType := dtPDF;
Report.Print;

I'll get an empty PDF file and an error after opening in Adobe Reader,
running windows 2003 x64, in Windows 7 x64 everything is Ok.

The PDF-files sizes ar 32.4KB.

The Error is: There was a problem reading this document (14)

Met vriendelijke groet,

Désirée Willemsen

Comments

  • edited February 2011
    Hi Desiree,

    Which version of ReportBuilder and Delphi are you using? Are you able to
    successfully export a report with a static Richtext component present? What
    about a simple report with just a label or memo?



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    Hi Nico,

    I'am using Report Builder 12.02 and Delphi 2010.

    I've tried an static RichText Component everything looks like normal, the
    PDF was readable.

    But when using this:

    TextEditor.LoadFromFile(RTFTemplate);
    TextEditor.MailMerge := True;
    Report.TextFileName := RTFOutputFile;
    Report.DeviceType := dtRTF;
    Report.Print;

    TextEditor.LoadFromFile(RTFOutputFile);
    TextEditor.MailMerge := False;
    Report.TextFileName := PDFOutputFile;
    Report.DeviceType := dtPDF;
    Report.Print;

    This also returns an empty PDF file.

    In the RTF file generated was also a strange issue. Carriage Returns are
    placed in the middle of the document, the template i use doesn't contain
    them. I've solved this issue by deleting some RTF. Maybe this happens also
    while generating the PDF which may corrupt the file.

    Can I send you the Corrupt PDF or the RTF (Template)?

    Thanx
    Desiree


  • edited February 2011
    Hi,

    I've found the problem.

    OldDec := DecimalSeparator;
    OldThousand := ThousandSeparator;
    try
    DecimalSeparator := ',';
    ThousandSeparator := '.';

    TextEditor.LoadFromFile(RTFTemplate);
    TextEditor.MailMerge := True;
    Report.TextFileName := PDFOutputFile;
    Report.DeviceType := dtPDF;
    Report.Print;
    finally
    ThousandSeparator := OldThousand;
    DecimalSeparator := OldDec;
    end;

    Running this code in a Windows-Service changes some characters inside the
    PDF-File which corrupt the file. I've changed floatfields to into
    stringfields and formatted it by self. It works fine.

    Greetz
    Desiree.



  • edited February 2011
    Hi Desiree,

    Thanks for the update.

    Yes, starting with RB 12, it is now necessary to change the ppFormatSettings
    global property each time you alter the Delphi global FormatSettings values.

    For instance...

    uses
    ppUtils;

    begin

    DecimalSeparator := ',';
    ThousandSeparator := '.';

    ppFormatSettings.DecimalSeparator := DecimalSeparator;
    ppFormatSettings.ThousandSeparator := ThousandSeparator;



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    Op 21/02/2011 15:28, Nico Cizik (Digital Metaphors) schreef:

    Hi Nico,

    can this be done one time at startup of the application or should this
    be done each time a report is created?

    Thx,
    Bernaert Dominique
  • edited February 2011
    Hi Bernaert,

    Since this is a global property, it only needs to be set once at startup (or
    each time the Delphi FormatSettings are altered).



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    Op 21/02/2011 15:33, Nico Cizik (Digital Metaphors) schreef:

    Could a change in dateseparator or time format be the cause of empty
    pdf-files?

    Dominique
  • edited February 2011
    Hi Dominique,


    No, only changing the ThousandSeparator and DecimalSeparator will affect PDF
    output however it is still recommended that you keep the ppFormatSettings in
    sync with any changes you make to the FormatSettings object.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2011
    Nico

    Perhaps a sill question but how do you keep the ppFormatSettings in sync
    with any changes you make to the FormatSettings object. Is it as simple as
    ppFormatSettings := FormatSettings?


    Regards

    Tim Murfitt
  • edited February 2011
    Hi Tim,

    Yes, this should work as well.



    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2011
    Hello Nico,

    Some of my customers have this problem of an empty PDF too.
    They all work on Windows 7 Home Premium.
    User on Vista or XP don't seem te have this problem.

    Regards,
    Stef
  • edited November 2011
    By the way I'm using RB12.05.2 on Delphi 2007.

    Hello Nico,

    Some of my customers have this problem of an empty PDF too.
    They all work on Windows 7 Home Premium.
    User on Vista or XP don't seem te have this problem.

    Regards,

    Stef
  • edited November 2011
    Hi Steph,

    Are you changing the FormatSettings like the others in this thread? If
    so you will also need to alter the ppFormatSettings as well.

    If this is not the issue, please send me a copy of one of the empty PDF
    files and I'll take a look at it for you. Send the file to
    support@digital-metaphors.com.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2011
    Hello Nico,

    Yes, I do change the FormatSettings and now the ppFormatSettings as well.
    This works fine.

    I just posted my findings so you know that this issue aparently isn't related
    to all operatingsystems.

    Regards,
    Stef
  • edited December 2011
    Hi Stef,

    I understand now. Thank you very much for the information.

    Best Regards,

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