fuzzy bitmaps when loading from an RTF file

  • I'm trying to accurately reproduce RTF files into PDF. I'm loading the RTF file with its embedded images into an TWPCustomRtfEdit and exporting it to PDF using TWPPDFExport, using the RTF file as a template and manipulating the text content prior to exporting to PDF. This works well enough, preserves formatting etc.

    However when I embed images in the RTF, they come out really fuzzy in PDF. The only way I know to get around this at the moment is to use the TWPPDFExport.DrawBitmap function but on multiple page RTF documents this function seems to Draw the bitmap onto every page at the same dimensions. I'd much prefer to use this function than embed images if there's a way to do this without the images appearing on every page? This way I can have one copy of each image as a resource in a DLL and keep the template filesizes to an absolute minimum.

    • Offizieller Beitrag

    Hi,

    If the images appear to be fuzzy please check thge property JPEGMode. Maybe you can use a higher value or set it to NoJPEG.

    TWPPDFExport.DrawBitmap does not automaticyll create a bitmap on every page. You will need to check the page number in the OnBeforePrintPage event before you draw.

    If you want to draw the bitmap several times use DrawBitmap once and store the result. Use DrawBitmapClone for each additional draw.

    Julian Ziersch

  • Essentially I need to be able to drop bitmap images into the document as its produced dynamically, and their position on their page will depend on the flow of content, eg it will be a relational position rather than fixed.

    At the moment I can either place the bitmap in the RTF and then it comes out fuzzy or I can use DrawBitmap and it comes out crisp but for the latter I have to specify coordinates I won't know and that won't be fixed. For this reason really I need the images from within RTF to just keep their quality.

    I've tried playing with the ConvertJPEGData and ConvertMetafileToBitmaps properties but I'm using WPTools5 and wPDF2 and still getting fuzzy images.

    • Offizieller Beitrag

    Hi,

    I really don't understand why you don't get the same quality. Please use the latest WPTools version. It should embed JPEG files without any change into the PDF.

    Can you send me little example of your code?

    In my example I used this properties:

    WPRichText1.AcceptFiles := TRUE;
    WPRichText1.TextObjects.DefaultPositionMode := wpotPage;

    (I will add an new property AcceptFilesOptions to the next release since changing DefaultPositionMode can have sideffects. You can also use the OnDropFile event to create the image)

    Then dropped a JPEG image, moved it around and exported with wPDF - prefect.

    Julian Ziersch

  • I still don't understand why the quality wasn't maintained but I guess that's something specific with the reading of embedded graphics on the RTFEdit component. I solved this problem in the end by using the TWPOImage object and mailmerge to place images throughout the document dynamically at runtime as suggested by simonwilsher.