PDF Viewer

Applies to HTML Viewer, IE Browser publications.

HTML Executable lets you integrate a stand-alone PDF viewer in your publications and ebooks. Your end users can view and read PDF documents compiled in your publication without the need of Adobe Reader or any other PDF reader.

Using the built-in PDF viewer lets you keep your PDF documents as secure as possible: they are not unpacked to the hard disk, so they cannot be copied by your users.

Watch our video tutorial about how to convert a PDF into an ebook with HTML Executable. Moreover, we added some additional customization steps like: disabling Print, Print Screen…, adding a password protection (and you can even go further thanks to the security features of HTML Executable), integrating a splash screen, changing the ebook window’s look, creating a custom icon for your ebook EXE file thanks to our icon software GConvert - and much more.

Displaying PDF documents in your ebook or publication

To enable the built-in PDF viewer, go to Application Settings => PDF Viewer and turn on: “Use the built-in PDF viewer in this publication”.

If the built-in PDF viewer is not used, the default PDF reader installed on the end user’s computer may be used:

  • in HTML Viewer publications, Adobe Reader is used to display PDF documents inside the publication’s main window.

  • in IE publications, any PDF reader compatible with Internet Explorer should work.

In cases you are unable to display PDF documents correctly, add the “_heopenit” target to the anchor tag as shown in the following HTML code:

<a href="mydoc.pdf" target="_heopenit">Open my PDF document</a>

This will force the publication to open the “mydoc.pdf” file in the default PDF reader.

About the Built-in PDF Viewer

The built-in PDF engine handles almost all PDF documents fine: PDF files created by popular printer drivers, Adobe Acrobat, Microsoft Office or OpenOffice should be displayed and printed fine. However, PDF files created by imaging and advanced publishing tools may not be properly displayed. If this is the case, printing your PDF document using a printer driver such as PDF Creator may help.

Please keep in mind that the PDF engine is small and it cannot compete with professional reader tools like Adobe Reader. The primary goal of the PDF engine is to display simple documents. Anyway, if you get troubles with a PDF file, you can submit it to our technical support team for review. We do not guarantee however that we can come up with a solution in all cases. However, the defect PDF file may be used to improve the engine.

Features available with the Built-in PDF Viewer

HTML Executable comes with a sample named “PDF Viewer” that illustrates the following features. You can compile this sample either by going to the “HTML Executable Samples PDF Sample” folder on your hard drive, or choose “Samples => PDF Viewer” when you start HTML Executable.

PDF Demo

Thumbnails, bookmarks, text selection, page printing, page navigation, page rotation, zoom in and out functions are available.

Note: you can disable the “page rotation” feature in the Application Settings => PDF Viewer page. Page rotation is not compatible with text selection. You can also disable the View Commands panel.

It is possible to enable the display of the navigation bookmark panel at startup: when the PDF is loaded, its bookmarks are automatically listed. You can disable this feature at any time thanks to the HEShowPDFBookmarks global variable. You can set the with of the panel thanks to Navigation Panel Initial Width (in pixels).

Thumbnails are enabled by default. If you want to disable them, enable “Disable Page Thumbnails panel”.

The PDF viewer can remember last current page of PDF files: when a user navigates from a PDF to another document, the PDF viewer stores the page number of the PDF. If the user comes back to the latter, the last page is restored. A menu option is also made available so that end users can disable this behavior if they want.

Non-Latin characters are supported.

PDFs are indexed by the search engine like HTML pages and included in search results if you enable “Index content from PDF files with the search engine” option in the Application Settings => PDF Viewer page. Specific PDF files can be excluded from the search thanks to File Properties - Security. It is possible to index PDF files even if the built-in PDF viewer engine is disabled. In that case, the default PDF reader will be used to display documents when a user clicks a search result.

However, after a search process, results from PDF documents will appear at the end of the list. If you want results from PDF documents to be treated as HTML ones when sorting by relevance, you need to turn this other option on: “Take PDF files into account while sorting search results by relevance”. But note that this will automatically make your publication bigger (more or less depending on the size of your PDFs), since HTML Executable must convert PDF documents to raw text data and store this data into the publication. By default, this option is turned off to keep publications small.

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>

Security profiles can be applied to PDF documents too: you can restrict access to PDF documents, define user rights like text copying, page printing…

The PDF engine displays the document title (read from PDF metadata) in the title bar and in search results.

Hyperlinks are supported by the PDF viewer. By default, these hyperlinks are highlighted (their background is grey) to inform the user they can be clicked (no hand cursor is displayed because the engine does not handle it). You can prevent this highlighting by checking the “Do not highlight hyperlinks in PDF files” option.

PDF files can be used in the Table of Contents.

Note: it is not possible to highlight a searched item in a PDF file (without HTML) and NOT allow the text to be copied using HTML Executable.

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; 
Path: String;

Path := OpenFileDialog("Choose the PDF to open", "*.pdf", "*.pdf", "PDF Files (*.pdf)", "");
if Path = "" then exit;

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 IDDescription
54Select the paper color. Param is a RGB value.
141Choose 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.
30Show printer selection and setup dialog. Param = 0
32Show the printer dialog. Param = 0
22Go 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);
 PDFViewerCommand(141, 0);

Copyright G.D.G. Software 2019. All rights reserved