PDFium library

Just starting out? Need help? Post your questions and find answers here.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

PDFium library

Post by boddhi »

Hello everybody,

I need a little (a lot) of help using the pdfium lib.
I am, as the French say, a Sunday programmer and my technical capabilites are very limited in external library usage.

What I'm looking for is to retrieve text areas from PDF files.
After some research, I found this post

As the github link was no longer valid, I turned to this one:

In this package, I found the pdfium.dll.lib file. From there, I tried two approaches:

1) Follow seeker's instructions
seeker wrote:polib %1.dll /machine:X64 /out:%1.lib
But when I run its example code with
Import "MyCustomDir:\pdfium.lib"
an error message "LINK: fatal error LNK1181 canno't open file - "MyCustomDir:\pdfium.lib"" appears.

2) Use the original pdfium.dll.lib provided in the package with
Import "MyCustomDir:\pdfium.dll.lib"
But same error message!

Does anyone know why this error occurs?
Where am I doing (surely :mrgreen: ) something wrong?

Thanks.

PS : Oops! I forgot to mention that I'm using Win10-x64 & PB6.10 b1
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PDFium library

Post by normeus »

Follow infratec's instructions here:
https://www.purebasic.fr/english/viewto ... 10#p553210


Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

@normeus
normeus wrote: Follow infratec's instructions here:
Thanks for you response.

But I still have a problem and errors.

Where do I put this lib?
1) When I put it in the source code folder
  • with

Code: Select all

ImportC "pdfium.dll.lib"
I get the following message: "Can't run the code because pdfium.dll.lib can't be found. Reinstalling the program may correct this problem."
[/quote]
  • with

Code: Select all

ImportC "VolumeLetter:\MySourceDir\pdfium.dll.lib"
I get the following message: "LINK: fatal error LNK1181 canno't open file - "MyCustomDir:\pdfium.dll.lib"

2) When I put it in the PB libraries folder ("PB folder\PureLibraries\Windows\Libraries\")
  • with

Code: Select all

ImportC "pdfium.dll.lib"
I get the following message too: "Can't run the code because pdfium.dll.lib can't be found. Reinstalling the program may correct this problem."

3) When I put it in the user libraries folder ("PB folder\PureLibraries\UserLibraries\")
  • with

Code: Select all

ImportC "pdfium.dll.lib"
I get the following message: "LINK: fatal error LNK1181 canno't open file - "MyCustomDir:\pdfium.dll.lib"
:(

It make me crazy :D
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PDFium library

Post by infratec »

As far as I know, there is no static lib file.

My version uses the pdfium.dll.lib to get the informations about the functions inside of the dll.
So your exe needs the pdfium.dll beside.

At compile time the file pdfium.dll.lib should be in the folder of your pb file.

For development in such a case, you should enable 'create temp executable in source directory' (not the exact words).
I use this in general.
Then you can put the lib and the dll file beside your sourc code.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

Hello Infratec,
infratec wrote: Thu Jan 11, 2024 12:35 pm At compile time the file pdfium.dll.lib should be in the folder of your pb file.
Thank you, firstly, for your code and, secondly, for your reply. :wink:

If I understand correctly, the pdfium.dll.lib and pdfium.dll files "must" both be in the same folder ?!
So the call to polib.exe would be useless?

I can't test now but I'll try as soon as I can.

Thanks again. :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PDFium library

Post by infratec »

If you alreday own the lib file and the dll file, then you don't need to call something.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

Newbie's question: There is a way to have only one file (pdfium.dll)?
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PDFium library

Post by normeus »

you need both files.
pdfium.dll.lib ( symbol table that "describes" the contents of pdfium.dll )
pdfium.dll ( the actual dll)

Three files total if you include your exe.

I tried Infratec's code today and it worked great: (https://www.purebasic.fr/english/viewto ... 10#p553210

1.- Downloaded "pdfium-win-x64.tgz" from https://github.com/bblanchon/pdfium-binaries.
2.- Extracted two files pdfium.dll and pdfium.dll.lib and saved them at the same location were the source code is located "E:\pb\pdfium\" in my case.
3.- Made sure that the setting for "Create temporary executable in the source directory" in File->Preferences->Compiler->Defaults was enabled.
4.- I downloaded the purebasic book pdf from: https://www.purebasic.com/documentation ... cSmall.pdf
5.- I was able to open PureBasic.pdf and read text from the pages no problem.

Norm
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

normeus wrote: you need both files.
Ok.
One last question (I don't want to seem very insistent :mrgreen: but it's not clear in my mind): Why do some codes use a dll and don't need a .dll.lib file?
normeus wrote: 1.- 5.
In the meantime, I've already done it, tested it and can confirm that it works correctly :wink: . Thanks anyway for your reply :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
normeus
Enthusiast
Enthusiast
Posts: 475
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: PDFium library

Post by normeus »

In this case "dll.lib" is like a catalog of functions for the "dll" file.
Once you are happy with your program and created an exe file then you do not need the "dll.lib" file anymore, because it is only used by the compiler/linker to know where the different functions are located in the "dll" file.

You only need your program and the dll file in the program's directory for it to run once compiled. Sorry if that was not mentioned before.

for an explanation of "lib" and "dll" take a look at stackoverflow:

this question:
https://stackoverflow.com/questions/913 ... at-and-why
and also this question:
https://stackoverflow.com/questions/311 ... inked-mean

Happy Coding!
Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

normeus wrote: In this case "dll.lib" is like a catalog of functions for the "dll" file.
Thanks a lot for this explanation.
I can see a bit more clearly now (as Jimmy Cliff used to say :mrgreen: ).

So, if I've understood correctly, for example, the .lib in the PureLibraries\Windows\Libraries folder are the indexes of the Windows dlls procedures needed to compile... I'm right? :mrgreen:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
infratec
Always Here
Always Here
Posts: 7664
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PDFium library

Post by infratec »

boddhi wrote: Thu Jan 11, 2024 11:08 pm Newbie's question: There is a way to have only one file (pdfium.dll)?
Yes.
But the lib file is not needed for execution.

You can use OpenLibrary(), Prototypes and GetFunction().
Then you don't need the lib file. But you have to create the Prototypes of the imported functions.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PDFium library

Post by boddhi »

@infratec

OK, OK, as we said in French, I'm starting to attach the wagons to the locomotive. :mrgreen: :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply