- Offizieller Beitrag
If you have a WPViewPDF control on a child unit the recommended way is to load the WPViewPDF engine from the main form, i.e. with this code:
Code
{$I PDFLicense.INC}// please add "WPViewPDF3" to uses clauseprocedure TViewMain.FormCreate(Sender: TObject);var viewerdll : String;begin {$IFDEF WIN64} viewerdll := ExtractFilePath( Application.ExeName ) + WPViewPDF_DLLName64; {$ELSE} viewerdll := ExtractFilePath( Application.ExeName ) + WPViewPDF_DLLName; {$ENDIF} if not WPViewPDFLoadDLL( viewerdll, true) then begin ShowMessage('PDF Viewing is not available'); SelectPDFFile.Enabled := false; end;end;
The childform with the viewer can then be created with a few lines of code:
Code
procedure TViewMain.SelectPDFFileClick(Sender: TObject);
begin
if OpenDialog1.Execute then
with TPDFView.Create(Self) do
try
// Not here, that would be to late - the control would have already tried the default path
// WPViewPDF1.DLLName := path + 'wPDFViewPlus03.dll';
// Set the license keys
WPViewPDF1.ViewerStart( '', WPViewPDF_LicName, WPViewPDF_LicKey, WPViewPDF_LicCode );
// Load
WPViewPDF1.LoadFromFile( OpenDialog1.FileName );
// Show form, non modal
Show;
except
Free;
end;
end;
Alles anzeigen
Note: Assigning a different name to WPViewPDF1.DLLName can be problematic, if the DLL was already loaded automatically.