Problem loading PDF file
a library to create/modify PDF documents using HDC/TCanvas
Brought to you by:
mc-zyx
I am using LitePDF for Delphi on Lazarus under Windows 10, and find that an exception is created when I try to load a particular file (attached). The pascal instruction is: n := LoadPDF(MainPDF,MainName.Text) where MainPDF is a TLitePDF class object. The same software loads many other different PDF files with no problem. I had originally suspected that the problem was caused by the length of the file name, but having shortened the name drastically the problem still remained.
I should perhaps have added that the definition of function LoadPDF is
function TPDFEditForm.LoadPDF(Instance:TLitePDF;filename:string):word;
begin
Result := 0;
try
Instance.LoadFromFile(filename,'',true);
Result := Instance.GetPageCount;
except
on exception do;
end;
end;
I can report that I have solved the problem that I had. Using the procedure "LoadfromFile", the filename C:\Users\melto\Downloads\IMSLP598443-PMLP9893-VIERNE_24_pièces_en_style_libre_Op.31(2-2).pdf was not correctly provided to the dll. The system was upset by the grave accent in "pièces". I have now changed my call to LoadfromFileW, and everything works fine.
My post probably doesn't call for any action from the creators of LitePDF, but may be of use to other users.
Thanks for a bug report. What is the exception you get, please? It can be the file is somehow broken, the PoDoFo library is rather strict. Also, what version of the litePDF do you use, please? There had been done a release last week, which contains the latest stable release of the PoDoFo library, which is responsible for opening (and in general manipulating) the PDF files.
The exception was "File doesn't exist" which fooled me as it had been selected by an open dialog component. The problem was caused by my use of "LoadfromFile" when I should have used "LoadfromFileW", so the file name was mangled in its transfer to the library. It was a French grave accent which caused the problem. Everything is now working correctly.
Ah, I see, I overlooked the Unicode letter in the name. I thought there's something in the file, which triggers some of the PoDoFo checks for PDF file validity, which can have false positives (there was one such file shown in the past). Good it was not it.