OS: Windows Server 2016. DLL: DebenuPDFLibrary64DLL1013.dll
Lazarus 3.4 (rev lazarus_3_4) FPC 3.2.2 x86_64-win64-win32/win64
I have never done this before.
I am stuck at how to properly load the library, and also how to use functions in the library.
According to the Getting Started:
("DPLDrawText" and "DPLSaveToFile" are just example function calls to demonstrate)
int InstanceID;
InstanceID = DPLCreateLibrary();
if (DPLUnlockKey(InstanceID, "your license key") == 1) {
DPLDrawText(InstanceID, 100, 500, "Hello world");
DPLSaveToFile(InstanceID, "C:\Docs\HelloFromDLL.pdf");
}
DPLReleaseLibrary(InstanceID);
Further from the same document: Sending Strings
char * Buffer;
char * Content = ...; // pointer to the data
Buffer = DPLCreateBuffer(10000);
DPLAddToBuffer(InstanceID, Buffer, Content, 10000);
DPLStoreCustomDataFromString(InstanceID,
"MyData", Buffer, 1, 0);
DPLReleaseBuffer(InstanceID, Buffer);
Further from the same document: Receiving Strings
unsigned char * Content;
int ContentLength;
Content = DPLRetrieveCustomDataToString("MyData", 1);
ContentLength = DPLAnsiStringResultLength(// copy the data in Content now
This is my own code, so far:
unit u_dll_pdf;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, u_gv;
type
TfunStringBack = function(strIn : string) : PChar; stdcall;
TfunCreateLibrary = function() : PChar; stdcall;
function GetPgImgStrFromPDF(const fnm: String; const pg, zm: Integer; var pgc: Integer; var img_str: String): Boolean;
implementation
function GetPgImgStrFromPDF(const fnm: String; const pg, zm: Integer; var pgc: Integer; var img_str: String): Boolean;
var LibHandle: THandle; fncPtr: Pointer; InstanceID: Integer; funCreateLibrary: TfunCreateLibrary;
begin
Result := True;
try
LibHandle := LoadLibrary(PChar(GV.RBI.QPDF_lib_fnm));
if LibHandle = 0 then
begin
Result := False;
Exit;
end;
fncPtr := GetProcAddress(LibHandle, 'DPLCreateLibrary');
if not Assigned(fncPtr) then //-- Error! Unknown data.
begin
Result := False;
Exit;
end;
// Everything is lined up. Time to call the function
finally
if LibHandle > 0 then
FreeLibrary(LibHandle);
end;
end;
end.
Ultimately, the function I need to get working is this one:
(I need to get a page from the .pdf file, to an HTML string)
RenderPageToString
Description
This function renders a page from the selected document to a string. The data in the returned
string depends on the Options parameter.
Syntax
Delphi
function TDebenuPDFLibrary1013.RenderPageToString(DPI: Double; Page, Options: Integer): AnsiString;
DLL
char * DPLRenderPageToString(int InstanceID, double DPI, int Page,
int Options);
Parameters
DPI The DPI to use when rendering the page. Values over 300 will cause excessive memory usage.
Page The page number to render
Options 0 = BMP output
1 = JPEG output
2 = WMF output
3 = EMF output
4 = EPS output
5 = PNG output
6 = GIF output
7 = TIFF output
8 = EMF+ output
9 = HTML5 output
10 = TIFF (G4) output
Many thanks to anyone who can get me over this learning curve.