Page 1 of 1
PDFium library
Posted: Thu Jan 11, 2024 1:32 am
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

) something wrong?
Thanks.
PS : Oops! I forgot to mention that I'm using Win10-x64 & PB6.10 b1
Re: PDFium library
Posted: Thu Jan 11, 2024 3:00 am
by normeus
Re: PDFium library
Posted: Thu Jan 11, 2024 11:03 am
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
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
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
I get the following message: "LINK: fatal error LNK1181 canno't open file - "MyCustomDir:\pdfium.dll.lib"
It make me crazy

Re: PDFium library
Posted: Thu Jan 11, 2024 12:35 pm
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.
Re: PDFium library
Posted: Thu Jan 11, 2024 1:24 pm
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.
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.

Re: PDFium library
Posted: Thu Jan 11, 2024 2:20 pm
by infratec
If you alreday own the lib file and the dll file, then you don't need to call something.
Re: PDFium library
Posted: Thu Jan 11, 2024 11:08 pm
by boddhi
Newbie's question: There is a way to have only one file (pdfium.dll)?
Re: PDFium library
Posted: Fri Jan 12, 2024 1:10 am
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
Re: PDFium library
Posted: Fri Jan 12, 2024 3:23 am
by boddhi
normeus wrote:
you need both files.
Ok.
One last question (I don't want to seem very insistent

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

. Thanks anyway for your reply

Re: PDFium library
Posted: Fri Jan 12, 2024 4:10 am
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.
Re: PDFium library
Posted: Fri Jan 12, 2024 5:07 am
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

).
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?

Re: PDFium library
Posted: Fri Jan 12, 2024 7:43 am
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.
Re: PDFium library
Posted: Fri Jan 12, 2024 9:18 am
by boddhi
@infratec
OK, OK, as we said in French, I'm starting to attach the wagons to the locomotive.
