0049-89-49053501 support@wptools.de

The PDFWorkBench is an object which can be created using some functions which can be imported from the WPViewPDF DLL.

This provides the developer with a powerful PDF manipulation tool which can be created and used very easy – in most developing languages under Windows OS.

No window class has tobe registered, no OCX has to be loaded, just import four easy to use functions.

By a simple call to ‘pdfWorkbenchCreate’ a new workbech object is created. It will be freed by ‘pdfWorkbenchFree’.
Using ‘pdfWorkbenchLoad’ a PDF file can be loaded or appended.

With ‘pdfWorkbenchCommand’ most commands IDs used by WPViewPDF can be sent to the work bench object.

This are the definitions of the functions:

fktpdfWorkbenchCreate = function(
licname, lickey: PWideChar; liccode: Cardinal ) : Pointer; stdcall;

fktpdfWorkbenchFree = function(
workbench : Pointer ) : Integer; stdcall;

fktpdfWorkbenchLoad = function(
workbench : Pointer;
Filename : PWideChar;
Append, InMemory : Integer ) : Integer; stdcall;

fktpdfWorkbenchCommand = function(
workbench : Pointer;
commandid : Integer;
intpar : Integer;
strpar : PWideChar;
ptr : Pointer ) : Integer; stdcall;

Under Delphi the function pointer are loaded by WPViewPDF3.pas:

wpview_pdfWorkbenchCreate := GetProcAddress(WPViewPDFDLLHandle,'pdfWorkbenchCreate');
wpview_pdfWorkbenchFree := GetProcAddress(WPViewPDFDLLHandle,'pdfWorkbenchFree');
wpview_pdfWorkbenchLoad := GetProcAddress(WPViewPDFDLLHandle,'pdfWorkbenchLoad');
wpview_pdfWorkbenchCommand := GetProcAddress(WPViewPDFDLLHandle,'pdfWorkbenchCommand');

In this example the workbech is created “on the fly” to just read out the page count.

procedure TForm1.TestnonvisualPDFworkbench1Click(Sender: TObject);
var workbench : Pointer;
s : String;
function CommandGetString(
id : Integer;
strparam : String = '';
intparam : Integer = 0 ) : String;
var
i: Integer;
begin
i := wpview_pdfWorkbenchCommand(workbench,id, intparam, PWideChar(strparam), nil);
if i > 0 then
begin
SetLength(Result, i);
wpview_pdfWorkbenchCommand(workbench, COMPDF_GetTextBufW, 0, nil, (@Result[1]) );
end
else
Result := '';
end;
begin
if OpenDialog1.Execute then
begin
if not assigned(wpview_pdfWorkbenchCreate) then
raise Exception.Create('wpview_pdfWorkbenchCreate is not available');
workbench := wpview_pdfWorkbenchCreate(PWideChar(LicName), PWideChar(LicKey), LicCode );
if not assigned(workbench) then
raise Exception.Create('wpview_pdfWorkbenchCreate failed');
try
s := OpenDialog1.FileName;
if wpview_pdfWorkbenchLoad( workbench, PWideChar(s), 0 , 0 )<0 then
raise Exception.Create('wpview_pdfWorkbenchLoad failed');
ShowMessage(
Format('This PDF File has %d pages. DLL-Version = %s', [
wpview_pdfWorkbenchCommand( workbench, COMPDF_GetPageCount, 0, nil, nil ),
CommandGetString(COMPDF_GET_DLLVERSION)
] )
);
finally
wpview_pdfWorkbenchFree( workbench );
end;
end;
end;