how to render to DC with colored/transparent background?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Post Reply
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

how to render to DC with colored/transparent background?

Post by ukograhl »

Hi,

using latest version 10.5.2.395 of SimpleDLL Viewer SDK I try to render a PDF page not against a white page background (which works fine) but to a given colored background.

To do this instead of using PXCV_DrawPageToDC I tried it with PXCV_DrawPageToDIBSection but whatever color I set, I always get a white background (render flags are set to 0, so pxvrpf_NoTransparentBkgnd is no issue and also raster renderer is used).

So what am I doing wrong? Can you modify your sample app .\DelphiExamples\PDFXEditSimple\ so that the rendered page uses a red or blue page background?

In general: Can a colored or transparent background can be achieved also using PXCV_DrawPageToDC ? Best would be a way to get the page rendered above any arbitrary content of an existing DeviceContent, so any coloring or other background content will stay partially visible.


Thanks,
Ulrich
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10959
Joined: Wed Jan 03, 2018 6:52 pm

Re: how to render to DC with colored/transparent background?

Post by Daniel - PDF-XChange »

Hello, ukograhl

Thank you for reaching out, I have informed our dev team of this case, and they will be looking into it as soon as they can. Unfortunately, I do not have an immediate answer I can provide you at the moment.

Just to clarify, you said you are using the version 10.5.2.395 of SimpleDLL Viewer SDK. Do you mean the "Editor Simple SDK" perchance? I don't believe the SimpleDLL Viewer SDK was ever updated beyond v2.5...

Also, if at all possible, could we request a snippet of the code running when you encounter such issues?

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

Re: how to render to DC with colored/transparent background?

Post by ukograhl »

Hello Daniel,

yes, Editor Simple SDK (using PDFXEditSimple.x64.dll) to render a PDF page.

Thanks!
Ulrich
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

Re: how to render to DC with colored/transparent background?

Post by ukograhl »

Oh, forgot to add the code:

- open your Delphi sample application .\Examples\DelphiExamples\PDFXEditSimple\
- on MainFrame.pas edit procedure TForm1.PaintBox1Paint(Sender: TObject);

Code: Select all

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  Res: HResult;
  Param: PXV_CommonRenderParameters;

  // new:
  hBmp: HBitmap;
  Btmp: TBitmap;
begin
  if(m_pDocument = 0) then
    Exit;

  Param.WholePageRect := @m_rWholePage;
  if(m_bFitPage)then
	Param.DrawRect := nil
  else
	Param.DrawRect := @m_rDrawPage;

  Param.RenderTarget := 0;
  Param.Flags := 0;

  with m_rWholePage do
	PaintBox1.Canvas.Rectangle(Left - 1, Top - 1, Right + 1, Bottom + 1);

  // Original Code
	{Res := PXCV_DrawPageToDC(m_pDocument, m_nCurPage, PaintBox1.Canvas.Handle, @Param);
	ErrorCheck(Res);  }

  // Testcode background:
  Res := PXCV_DrawPageToDIBSection(m_pDocument, m_nCurPage, @Param, 0, $FF0000FF, @hbmp, 0, 0);
  ErrorCheck(Res);

  Btmp:= TBitmap.Create;
  try
    Btmp.Handle:=hBmp;
    PaintBox1.Canvas.Draw(m_rWholePage.Left, m_rWholePage.Top, btmp);
  finally
    Btmp.Free;
  end;
end;
Should'nt this create a red background?
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10959
Joined: Wed Jan 03, 2018 6:52 pm

Re: how to render to DC with colored/transparent background?

Post by Daniel - PDF-XChange »

Hello, ukograhl

I believe you are correct, but I am not a Developer myself, so admittedly this does go a bit over my head.

I can confirm that we have a bug/investigation ticket in place for you on this issue now. Once that investigation is complete, you should see a reply here. For now, as with all tickets, this is an internal item, but the ticket number is as follows:

RT#7417: Delphi - Simple SDK - background color/transparency

I have added your code snippet to the notes as well, for quick access.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

Re: how to render to DC with colored/transparent background?

Post by ukograhl »

Hello Daniel!

Thanks for looking on this problem. Will wait for the results.


kind regards,
Ulrich
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

Re: how to render to DC with colored/transparent background?

Post by ukograhl »

Hi,

just a short question: have your developers been able to reproduce this? It would be interesting to hear if I'm doing something wrong or if it is a bug that will be fixed with coming versions.


Thanks,
Ulrich
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 10959
Joined: Wed Jan 03, 2018 6:52 pm

Re: how to render to DC with colored/transparent background?

Post by Daniel - PDF-XChange »

Hello, ukograhl

It does appear that the ticket is now "open" which generally does not happen until after a Developer has reached a point where they can claim it and begin work on the fix. However, there is no note I can see about the state of it at the moment, so It does not appear that this issue will be fixed in the 10.6 release coming later today. My apologies for the inconvenience.

Kind regards,
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
ukograhl
User
Posts: 6
Joined: Fri Apr 04, 2025 8:00 am

Re: how to render to DC with colored/transparent background?

Post by ukograhl »

Thanks, Daniel!

kind regards,
Ulrich
Post Reply