Error saving to PDF

  • Helo!

    My application have a option to save contents from wptools to PDF. But i'm getting a problem. I have a RTF with text and some images. When I save to PDF using wpdf, in the pdf created, the 2 first images show correct, but the third not. The third and forth images should be te same, but instead, the third image shows a copy of the FIRST image !!

    Any help?

  • I saw something similar in my application. I have no solution, only some questions for you:

    o do you happen to have

    Code
    WPExportEMFAsBitmap := true

    in your code?
    o is your document more than a single page?
    o is there a graphic in your header or footer?
    o Do you have Header/Footer set to something other than "First Page Only"?

    With all those conditions true for myself, I also get a repeating image where there should be a different one. In my case, change any of the conditions, and the problem goes away.

    diamond

    • Offizieller Beitrag

    Hi,

    Thanks to diamond for jumping in.

    Zitat

    My application have a option to save contents from wptools to PDF. But i'm getting a problem. I have a RTF with text and some images. When I save to PDF using wpdf, in the pdf created, the 2 first images show correct, but the third not. The third and forth images should be te same, but instead, the third image shows a copy of the FIRST image !!

    Is there something special to your app to replcae the images dynamically?

    If you do, please increment the global variable 'WPPDFRun' which is defined in unit WPObj_Image for each modification of the image or each appended copy of the document.

    The reason is that the PDF exportter tries to reuse images to make PDF files smaller. So if an image is used in a header or footer it is in fact only exported once and then reused on every page.

    Regards,
    Julian

  • Julian,

    Thanks for the suggestion! You've mentioned it in the past to me, but I didn't try it because I wasn't sure it fit my particular situation.

    I have the image repeating within the SAME (and ONLY) document when I output to PDF, rather than between different employees in the same print run - that's why I wasn't clear using WPPDFRun, and incrementing it, would apply here. Do I increment it after each inserted image within the SAME document, or was it intended to be incremented between submitted documents in the same print run?

    For me, it's not a case of printing a merged document for a number of employees, and the images repeat among the different employees, but rather when I print a merged document for just a SINGLE employee in the print job, the last image I insert into the document (at run time), is the one that gets repeated.

    If I do a preview or send output to printer, everything's perfect. This is only with PDF output (using V2 of PDF), and WPExportEMFAsBitmap set True.

    I can consistently reproduce this effect with a document containing just a few carriage returns, two images I insert at runtime, an embedded image in the footer, and an embedded form feed (recall I sent you that document).

    Thanks!

    diamond

    • Offizieller Beitrag

    Hi,

    If you have a project which does it don't hesitate to check out the original source code.

    In this case WPObj_Image.PAS - an execllent source for information about image objects.

    This code which would create the image COPY is

    Code
    if (WPPDFRun > 0) and (FPDFRun = WPPDFRun) then
                    WPWriteComment(toCanvas.Handle, 2001, BoundsRect, 'WPToolsJIF_' + IntToStr(FPDFNr))
                  else


    So if you set the WPPDFRun to -1 this should never be done and all images would be embedded, duplicates or not.

    Julian