#1 2022-09-15 19:55:41

skamradt
Member
Registered: 2022-09-15
Posts: 3

TGDIPages.AppendRichEdit() doesn't import some PNG images

I am using AppendRichEdit to print some RTF blobs, and I'm noticing that images which were added to the RTF as a png are not being converted, yet images added as a JPEG are.  Is there some magic that has to occur that I'm missing to allow png images to render properly?  The not working images are stored in the RTF as ...\pngblip\..., the working images are stored in the RTF as ...\jpegblip\...

The images render properly to the screen if I load the blob into a TRichEdit control, and also print if I use a FastReport report.

Offline

#2 2022-09-16 06:16:22

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: TGDIPages.AppendRichEdit() doesn't import some PNG images

The RichEdit is converted using raw EMR MetaFile records, in which there is no notion of jpeg or png, only bitmaps.

SynPdf handles the regular EMR_BITBLT EMR_STRETCHBLT EMR_STRETCHDIBITS EMR_TRANSPARENTBLT records, converting the bitmaps into pdf images.
My guess is that the issue is that the RichEdit component you use is not able to render png images.

Are you sure your RichEdit is created in version 5.0 not 2.0?
https://stackoverflow.com/q/54570552/458259

Or you may try to include the image as bitmap not png and use \wbitmapN or \dibitmapN tags.
See https://www.biblioscape.com/rtf15_spec.htm

Offline

#3 2022-09-16 20:26:10

skamradt
Member
Registered: 2022-09-15
Posts: 3

Re: TGDIPages.AppendRichEdit() doesn't import some PNG images

Some oddness going on for sure.  The RichEdit (vanilla from Delphi 11 components) appears to be rendering the png images properly on the screen, its just when it goes to insert into the report that the png images are getting removed. Unfortunately I'm not able to change the format of what is in the RTF fragments, most of the time they are pasted in screen shots and I have records going back several years.  The fast report export was working, but it renders everything as an image (including text) which breaks the ability to do a text search on the document or feed the pdf through a screen reader.

Offline

#4 2024-02-29 04:00:26

MichaelFedderson
Member
Registered: 2023-04-13
Posts: 2

Re: TGDIPages.AppendRichEdit() doesn't import some PNG images

I understand it's been a while since your post about TGDIPages.AppendRichEdit() and PNG image import issues. If you're still encountering this problem, have you considered revisiting the implementation? Sometimes, after a couple of years, new updates or solutions become available. Additionally, exploring alternative methods like converting PNGs to JPEG format before adding them to the RTF might provide a workaround.
Tools like jpg compress can assist in optimizing image compatibility. Don't hesitate to reach out if you need further assistance or if there have been any developments since your original post!

Last edited by MichaelFedderson (2024-03-01 14:14:58)

Offline

#5 2024-02-29 07:45:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: TGDIPages.AppendRichEdit() doesn't import some PNG images

The RichEdit Windows component is a black box.
If it does not PNG export support, I do not see how to do it.

What could be done is to add images as plain bitmaps. SynPdf will save them with deflate encoding, just like a PNG.

Offline

Board footer

Powered by FluxBB