ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to render a PDF page with background color?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
uko Posted - May 21 2025 : 06:03:17
Hi

I try to render a PDF page on a bitmap with a defined background color (red) but I always get a white page background. This the code I use:

    var lDoc := TPdfDocument.Create;
    try
      lDoc.LoadFromFile('d:\downloads\test_text_back.pdf');
      
      var bmp := TIEBItmap.Create(200, 400, clRed, 255);
      try
        IERenderPDFToBMP(bmp.VclBitmap, lDoc, 0, 200, 400, pw, ph, dpiX, dpiY, prNormal, clRed);

        bmp.DrawToCanvasWithAlpha(self.Canvas, 100, 100);
      finally
        bmp.Free;
      end;
    finally
      lDoc.Free;
    end;


The PDF self has just some text on a single page without background. So what am I doing wrong here?


kind regards,
Ulrich
6   L A T E S T    R E P L I E S    (Newest First)
uko Posted - Jun 02 2025 : 00:53:59
Hi Nigel,

thanks for looking onto this!


kind regards,
Ulrich
xequte Posted - Jun 02 2025 : 00:36:05
Hi Ulrich

Sorry, at this time, PDF transparency is not supported and would take time to implement and test.

I have added it to the to-do list for a future version.

Note, also, PDFium does not consider your example above to be transparent.

Nigel
Xequte Software
www.imageen.com
uko Posted - May 22 2025 : 03:46:20
Thanks!

kind regards,
Ulrich
xequte Posted - May 22 2025 : 03:21:57
Hi Ulrich

OK, I'm not sure that we implement support for transparent PDF files (as it is not needed for the viewer). I'll need to look into that when I'm back in the office at the end of the May.

Nigel
Xequte Software
www.imageen.com
uko Posted - May 22 2025 : 01:39:24
Hi Nigel,

please look on the attached PDF

Download Attachment: 202552203716_test_text_back.pdf

When you change Adobe Reader to show a transparency grid (page display settings) it shows the page to be entirely transparent with exception of the two text areas.

So using pagecolor parameter of IERenderPDFToBMP I would have expected to see most of the page red with exception of white text areas.

Changing the color after rendering is not a good idea: what if the PDF contains some white areas as content that should appear white (say inside an image or similar)?


kind regards,
Ulrich
xequte Posted - May 21 2025 : 15:52:11
Hi Ulrich

The PDF will have a white background, so the red will be replaced by the white.

You should make the image transparent before drawing it onto the red, or just cast the white color as red:

http://www.imageen.com/help/TImageEnProc.CastColorRange.html

Nigel
Xequte Software
www.imageen.com