Rank: Newbie
Groups: Registered
Joined: 7/19/2025(UTC) Posts: 6  Location: New Mexico Thanks: 1 times
|
I am trying to use the PDFium dlls with Delphi. Some things work and some things don't.
A couple of quick questions.
1) Should the calls to the dlls be stdcall or cdecl? 2) How big are the bool returns? 8, 16, 32, etc.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,123
Thanks: 8 times Was thanked: 131 time(s) in 128 post(s)
|
Hello,
pdfium.dll uses stdcall for all public API
|
 1 user thanked Paul Rayman for this useful post.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/19/2025(UTC) Posts: 6  Location: New Mexico Thanks: 1 times
|
Here is a snippet of my code: procedure TfrmOCGList.AdvGlowButton1Click(Sender: TObject); var pFileName: pAnsiChar; Version: AnsiString; Code: integer; rClear: TRect; vKeyList: TStringList; vIsVector, vIsDict: boolean; vKeyStr: AnsiString; vCount: integer; vError: integer;
begin // The following statements work FFileName := 'C:\Users\kbailey\Desktop\Testing 4P.pdf'; // with OpenDialog1 do // if Execute then // FFileName := ANSIString(Filename) // else // exit; Version := ''; Code := 0; try if not FPDFiumDLL.FPDF_InitLibraryEx(PAnsiChar(LicenseKey), PAnsiChar(Version)) then begin Code := FPDFiumDLL.FPDF_GetLastError; raise eMyException.Create('FPDF_InitLibraryEx Failed - Code: ' + IntToHex(Code, 8)); end;
except on E: Exception do begin raise; end; end; with PaintBox1 do begin
rClear := rect(0, 0, Width - 1, Height - 1); Canvas.Brush.Color := clWhite; Canvas.FillRect(rClear); end; with FPDFiumDLL do begin pFileName := @FFilename[1]; FDocument := FPDF_LoadDocument(pFileName, nil); vError := FPDF_GetLastError; vCount := FPDF_GetPageCount(FDocument); vError := FPDF_GetLastError; FPage := FPDF_LoadPage(FDocument, 0); vError := FPDF_GetLastError; FPDF_RenderPage (PaintBox1.Canvas.handle, FPage, 0, 0, PaintBox1.Width, PaintBox1.Height, 0, 0); vError := FPDF_GetLastError;
// Until here. FRoot := FPDF_GetRoot(FDocument); // Not sure this is working properly vError := FPDF_GetLastError; // vIsDict := FPDF_ISDictionary(FRoot); // Causes an AV if executed// vError := FPDF_GetLastError; vCount := FPDFDICT_GetCount(FRoot); // This returns 0 vError := FPDF_GetLastError; if vCount > 0 then begin vKeyStr := 'OCGProperties'; vIsVector := FPDFDICT_KeyExist(FRoot, vKeyStr) <> 0; // Causes AV if executed vError := FPDF_GetLastError; if vISVector then Label1.Caption := 'This a vector PDF' else Label1.Caption := 'This not a vector PDF'; end else Label1.Caption := 'Root count is 0!';
end; end; PDFiumDLL is an object that loads PDFium.dll and links the functions to the dll entries. Whenever I try to execute a function with a boolean return, I get an access violation. The return of the FPDF_GetRoot looks correct - it is in the same range as FDocument and FPage. But the GETCount returns 0.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,123
Thanks: 8 times Was thanked: 131 time(s) in 128 post(s)
|
Hi, FPDF_BOOL is defined like int. 0 - FALSE. 1- TRUE The code you provided looks fine. It should work. Here is a pure C example that works fine. Try porting it to Delphi first. Code:FPDF_BOOL isInitialised = FPDF_InitEx(YOUR_KEY_HERE, NULL);
//isInitialised must be true.
FPDF_BOOL test = FPDF_IsTrial(); //should be false. Optional call, just to make sure the library is initialized
test = FPDF_TestCompare(3); //must be true. Optional call. But dictionaries are only available on level 3 license. You must have the corresponding activation key.
FPDF_DOCUMENT hDoc = FPDF_LoadDocument("e:\\149\\test.pdf", NULL);
FPDF_DICTHANDLE hDict = FPDF_GetRoot(hDoc);
int count = FPDFDICT_GetCount(hDict);
FPDF_CloseDocument(hDoc);
I think I can provide the header files that are in preparation for public access. There you can see all the APIs and return types. Here you are pdfium.net.sdk.headers.4.100.2704.zip
|
|
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close