Recent

Author Topic: Porting PDF Viewer from Delphi  (Read 1042 times)

domasz

  • Hero Member
  • *****
  • Posts: 601
Porting PDF Viewer from Delphi
« on: November 11, 2025, 11:31:03 am »
There is a very nice component for Delphi that uses Pdfium. Made by Lasse Markus Rautiainen and Andreas Hausladen.
I tried porting to Lazarus but something is off.

Attached is full source code from 2 repos:
https://github.com/ahausladen/PdfiumLib
https://github.com/TextEditorPro/TTextEditor/
License: MIT

You'll need to put a DLL in x64 directory from:
https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F7242/pdfium-win-x64.tgz
You don't need to install anything.

Lazarus port compiles and runs but renders in a weird way. I don't see any changes in code in how things are rendered between Delphi and Lazarus

LV

  • Sr. Member
  • ****
  • Posts: 380
Re: Porting PDF Viewer from Delphi
« Reply #1 on: November 12, 2025, 11:16:24 am »
There is a very nice component for Delphi that uses Pdfium. Made by Lasse Markus Rautiainen and Andreas Hausladen.
I tried porting to Lazarus but something is off.

Attached is full source code from 2 repos:
https://github.com/ahausladen/PdfiumLib
https://github.com/TextEditorPro/TTextEditor/
License: MIT

You'll need to put a DLL in x64 directory from:
https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F7242/pdfium-win-x64.tgz
You don't need to install anything.

Lazarus port compiles and runs but renders in a weird way. I don't see any changes in code in how things are rendered between Delphi and Lazarus

I gathered the courage to make a few adjustments.  :-[

P.S. I slightly modified LazarusCode.zip above
« Last Edit: November 12, 2025, 11:28:03 am by LV »

domasz

  • Hero Member
  • *****
  • Posts: 601
Re: Porting PDF Viewer from Delphi
« Reply #2 on: November 12, 2025, 11:43:17 am »
Damn, you are good! Seems to be fixed, thanks!

Boleeman

  • Hero Member
  • *****
  • Posts: 1006
Re: Porting PDF Viewer from Delphi
« Reply #3 on: November 15, 2025, 12:38:46 pm »
Also came across Pdfium LCL at

https://github.com/DomenicoMammola/PdfiumPascal

but compilation stops at Uses PdfiumCore  in unit mainfrm2;

Attached is the zip from that github page.

Boleeman

  • Hero Member
  • *****
  • Posts: 1006
Re: Porting PDF Viewer from Delphi
« Reply #4 on: November 15, 2025, 06:21:52 pm »
Got it working with these files.

Can select between LCL, Graphics32, Image32

Annotate did not work.

Need to put pdfium.dll in the example/lcl folder
« Last Edit: November 16, 2025, 04:05:26 am by Boleeman »

domasz

  • Hero Member
  • *****
  • Posts: 601
Re: Porting PDF Viewer from Delphi
« Reply #5 on: November 16, 2025, 09:35:22 pm »
Also came across Pdfium LCL at

https://github.com/DomenicoMammola/PdfiumPascal

That's way worse- it doesn't support continuous scrolling

domasz

  • Hero Member
  • *****
  • Posts: 601
Re: Porting PDF Viewer from Delphi
« Reply #6 on: November 17, 2025, 11:08:24 am »
In PDFium.Control.pas, line 2089:

Code: Pascal  [Select][+][-]
  1. procedure TCustomPDFiumControl.PaintWindow(ADC: HDC);
  2. var
  3.   LIndex: Integer;
  4.   LPage: TPDFPage;
  5.   LBrush: HBrush;
  6. begin
  7.   LBrush := CreateSolidBrush(Color);
  8.   try
  9.     //FillRect(ADC, ClientRect, LBrush); this seems not needed. It draws a weird rectangle visible when scrolling

 

TinyPortal © 2005-2018