Skip to content

Print, Kiosk Printing and PDF

Applications made with ExeOutput for PHP can print webpages directly to a printer or as PDF files.

Print Button

You can customize some properties of the printing process thanks to the "Printer" component.

By default, print preview is enabled. This means that end users will see this dialog box when they select Print:

Print Preview


You can disable the Print Preview by setting EnablePrintPreview to false in the "Printer" component.

Direct print or kiosk printing

ExeOutput for PHP allows you to print, without prompting the end user, to the default printer. This is called kiosk printing.

First, to enable kiosk printing, edit the "Printer" component and make sure to set EnablePrintPreview to false and EnableKioskPrint to true.

Programmatically enable or disable kiosk printing / print preview

This is possible to enable and disable kiosk printing and/or print preview at runtime thanks to JavaScript, PHP or HEScript.

The following global variables are used internally by the PHP application to enable/disable kiosk printing or print preview. You can then change their values to modify the behavior.

Variable Name Description
PrintPreviewEnabled 1 or 0. If 1, print preview is enabled.
KioskPrintEnabled 1 or 0. If 1, kiosk printing is enabled.

For instance, the following code enables kiosk printing at runtime. Just add this HEScript code to the UserMain script:

procedure EnableKiosk;
 SetGlobalVar("KioskPrintEnabled", "1", false);
 SetGlobalVar("KioskPrintCopies", "1", false);
 SetGlobalVar("PrintPreviewEnabled", "0", false);
and you can invoke it from JavaScript or PHP (or associate it to an event).

The same code in JavaScript:

<script language="JavaScript">
exeoutput.SetGlobalVariable('KioskPrintEnabled', '1', false);
exeoutput.SetGlobalVariable('KioskPrintCopies', '1', false);
exeoutput.SetGlobalVariable('PrintPreviewEnabled', '0', false);

You can let end users export the current webpage as PDF. For instance, clicking the Print to PDF button will prompt the end user for the filename of the PDF file and it will then be saved to that location.

Print Button

Programmatically save directly to a PDF file

You can use PrintPDF and PrintPDFFile HEScript functions.

  • PrintPDF will do the same as described above (cliking the Print to PDF button).

  • PrintPDFFile will export the PDF directly to the file you specify.

For instance, the following code will export the current webpage as a PDF file. The PDF file is named "mydoc.pdf" and stored into the current user's My Documents folder. Just add this HEScript code to the UserMain script:

procedure ExportPDFSample;
 S: String;
 S := GetGlobalVar("HEMyDocDirectory", "C:") + "\mydoc.pdf";
and you can invoke this function from JavaScript or PHP (or associate it to an event or a UI control).

Another possibility with JavaScript: window.exportPDF(pdffilename) is a JavaScript extension available in ExeOutput apps. This lets you export the content of the window as a PDF file.

pdffilename lets you pass the full path and filename of the PDF file to be exported.

For instance:

<script language="javascript">
   // Callback for save dialog box - content contains the full path to the future PDF file.

    function DemoSavePDF(content) {
            if (content === "") return;

    function exportpdf() {
        // Run HEScript script SavePDFDlgFile defined in UserMain to get the PDF filename.
        exeoutput.GetHEScriptCom('hescript://UserMain.SavePDFDlgFile', DemoSavePDF);


See Also: "Printer" component