Recent

Author Topic: pdfiumLib port  (Read 1306 times)

taazz

  • Hero Member
  • *****
  • Posts: 5362
pdfiumLib port
« on: April 16, 2018, 10:38:27 pm »
Find attached a port of pdfium library https://github.com/ahausladen/PdfiumLib from delphi to lazarus 1.4.4 
If you want the pdfium dlls you can download a version from https://github.com/pvginkel/PdfiumViewer/tree/releases/2.12.0.0/Libraries/Pdfium
This is a windows only release, I was planning to extend it to linux and ultibo but my plate is to full at this time hopefully some one else can extend it or add a continues page scrolling.

Regards.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

rick2691

  • Sr. Member
  • ****
  • Posts: 348
Re: pdfiumLib port
« Reply #1 on: April 26, 2018, 02:03:18 pm »
What folder should the DLL be placed in? And which DLL should it be? ...x64 or x86?

Rick
Windows 10, LAZ 1.6.4, FPC 3.0.2, SVN 54278, i386-win32-win32/win64, forms use windows unit

taazz

  • Hero Member
  • *****
  • Posts: 5362
Re: pdfiumLib port
« Reply #2 on: April 26, 2018, 03:38:00 pm »
What folder should the DLL be placed in? And which DLL should it be? ...x64 or x86?
the same folder as your exe,
And which DLL should it be? ...x64 or x86?
depends on your exe. if your exe is 32bit you use the x86 if it is 64 bit you use the x64.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 86
Re: pdfiumLib port
« Reply #3 on: December 01, 2018, 01:22:13 am »
Hi,

I found that it was best to obtain this 2.12 package and extract the dll(s) as needed (7zip opens it ok)...

https://www.nuget.org/packages/PdfiumViewer/2.12.0

Its under Apache 2.0
https://www.apache.org/licenses/LICENSE-2.0

The unit PdfiumLib, within the project says to use...
https://github.com/pvginkel/PdfiumViewer/tree/master/Libraries/Pdfium
But there is a message there...
Quote
The native PDFium libraries have been removed from this repository. Please see the README or the PdfiumBuild for more information.

The ReadMe referenced is...
https://github.com/pvginkel/PdfiumViewer/blob/master/README.markdown

Also in the PdfiumLibExmaple project that the original .rar contains (lead post below), have a look in the code for MainFrm:-

Code: Pascal  [Select]
  1. procedure TfrmMain.FormCreate(Sender: TObject);
  2. begin
  3.   {$IFDEF CPUX64}
  4.   PDFiumDllDir := ExtractFilePath(ParamStr(0)) + 'x64';
  5.   {$ELSE}
  6.   PDFiumDllDir := ExtractFilePath(ParamStr(0)) + 'x86';
  7.   {$ENDIF CPUX64}

.. and you'll note that its out of the box expecting you to place the 64bit or 32Bit dlls as shown in a directory under your project, in appropriate directories (x64 or x86) - or as you choose, just adjust the code there.

(PDFiumDllDir is defined in PdfiumCore.pas and is initially set to look in the project's main path.

Code: Pascal  [Select]
  1. var
  2.   PDFiumDllDir: PDFString = '';
)

One way or the other, get these settings as you want them, then everything works just fine.

Also note that if you also need HTML rendering, the much bigger Chromium project, directly incorporates pdfium, and so can also show pdfs in the browser component window.

See http://wiki.freepascal.org/fpCEF3  ... If your using local pdf files you need to  use full file paths as in fpCEF3_Browser.Load('file://'+ fileName)

The pdfium control requires ...
TPdfControl.LoadFromFile(fileName)

Also in MainFrm frmMain.FormCreate
You may want to change:
FCtrl.PageColor := RGB(255, 255, 200);
to
FCtrl.PageColor := RGB(255, 255, 255);
if you don't want an initial yellow background.

Paul
« Last Edit: December 01, 2018, 04:41:57 am by PaulANormanNZ »

taazz

  • Hero Member
  • *****
  • Posts: 5362
Re: pdfiumLib port
« Reply #4 on: December 01, 2018, 11:39:23 am »
Hi,

I found that it was best to obtain this 2.12 package and extract the dll(s) as needed (7zip opens it ok)...

https://www.nuget.org/packages/PdfiumViewer/2.12.0

Its under Apache 2.0
https://www.apache.org/licenses/LICENSE-2.0

The unit PdfiumLib, within the project says to use...
https://github.com/pvginkel/PdfiumViewer/tree/master/Libraries/Pdfium
But there is a message there...
Quote
The native PDFium libraries have been removed from this repository. Please see the README or the PdfiumBuild for more information.
that's why I posted a link to the 2.12 version of the repository so you can download the dlls directly, which probably are the same as the packages you linked.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

PaulANormanNZ

  • Jr. Member
  • **
  • Posts: 86
Re: pdfiumLib port
« Reply #5 on: December 01, 2018, 12:51:04 pm »
Thanks Taazz,

I tried that link, and initially had problems with it - all seems ok now when I checked the 64bit one again...

https://github.com/pvginkel/PdfiumViewer/tree/releases/2.12.0.0/Libraries/Pdfium/x64

Paul