logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Tuesday, July 22, 2025 5:19:10 AM(UTC)
 
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
Sugarloafer Posted: Monday, July 21, 2025 7:56:00 AM(UTC)
 
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.

Paul Rayman Posted: Sunday, July 20, 2025 9:43:25 PM(UTC)
 
Hello,

pdfium.dll uses stdcall for all public API
Sugarloafer Posted: Saturday, July 19, 2025 5:30:41 PM(UTC)
 
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.