Navigation: Create Ebooks And Publications > Displaying PDF and Securing PDF as Ebooks >

Advanced Features for the PDF Viewer

 

 

 

 

For advanced users, here are some additional features provided by the built-in PDF viewer of HTML Executable.

 

Opening PDF to specific pages or bookmark

 

  You can link to specific pages by number or named locations:

 

For a specific page by number:

<a href="file.pdf#page=3">Link text</a>

 

For a named location (destination):

<a href="file.pdf#nameddest=TOC">Link text</a>

 

Loading external PDF files with HEScript

 

You can load external PDF files directly in the publication thanks to the HEScript command named "LoadPDFFromFile". Example:

 

procedure OpenPDFDialog; var Path: String;
begin 
Path := OpenFileDialog("Choose the PDF to open", ".pdf", ".pdf", "PDF Files (*.pdf)", "");
if Path = "" then exit;
LoadPDFFromFile(Path);
end; 

 

Sending commands to the PDF viewer engine

 

When the PDF viewer engine loads a PDF document, it triggers the OnPDFDisplay event. You can then pass commands thanks to the built-in HEScript functions named PDFViewerCommand and PDFViewerCommandStr.

 

List of available commands (and description / parameter value for PDFViewerCommand)

 

Command ID

Description

54

Select the paper color. Param is a RGB value.

141

Choose the renderer for screen display. The default is Param=1 which selects the GDI+ Renderer, Param=0 selects the AGG Renderer. The latter produces better looking letters and better scaled images (antialias), but implements only basic clipping. See code example below.

30

Show printer selection and setup dialog. Param = 0

32

Show the printer dialog. Param = 0

22

Go to the page number specified by Param. The first page has number 0.

 

The following script example lets you switch to the AGG renderer (insert it in UserMain)

procedure OnPDFDisplay(PDFPath: String); 
begin 
PDFViewerCommand(141, 0); 
end;