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

You can customize various properties of the printing process using the “Printer” component.
Print Preview #
By default, print preview is enabled. This means users will see the following dialog box when they select “Print”:

Tip
You can disable Print Preview by setting EnablePrintPreview to false in the “Printer” component.
Direct or Kiosk Printing #
ExeOutput for PHP allows you to print directly to the default printer without prompting the user—a feature known as kiosk printing.
To enable kiosk printing, edit the “Printer” component and set EnablePrintPreview to false and EnableKioskPrint to true.
Programmatically Toggling Kiosk Printing / Print Preview #
You can enable or disable kiosk printing and/or print preview at runtime using JavaScript, PHP, or HEScript.
The following global variables are used internally to control kiosk printing and print preview. You can modify their values to change the application’s behavior.
| Variable Name | Description |
|---|---|
| PrintPreviewEnabled | 1 (enabled) or 0 (disabled). |
| KioskPrintEnabled | 1 (enabled) or 0 (disabled). |
For example, the following HEScript code enables kiosk printing at runtime. Simply add this code to the UserMain script:
procedure EnableKiosk;
begin
SetGlobalVar("KioskPrintEnabled", "1", false);
SetGlobalVar("KioskPrintCopies", "1", false);
SetGlobalVar("PrintPreviewEnabled", "0", false);
end;This procedure can then be invoked from JavaScript or PHP or associated with an event.
Here is the equivalent code in JavaScript:
<script language="JavaScript">
exeoutput.SetGlobalVariable('KioskPrintEnabled', '1', false);
exeoutput.SetGlobalVariable('KioskPrintCopies', '1', false);
exeoutput.SetGlobalVariable('PrintPreviewEnabled', '0', false);
</script>Print to PDF #
You can allow users to export the current webpage as a PDF. For example, clicking the “Print to PDF” button prompts the user for a filename, and the PDF is then saved to the specified location.

Saving Directly to a PDF File Programmatically #
You can use the PrintPDF and PrintPDFFile HEScript functions.
PrintPDFperforms the same action as clicking the “Print to PDF” button.PrintPDFFileexports the PDF directly to a file you specify.
For example, the following HEScript code exports the current webpage to a PDF file named “mydoc.pdf” in the user’s “My Documents” folder. Add this code to the UserMain script:
procedure ExportPDFSample;
var
S: String;
begin
S := GetGlobalVar("HEMyDocDirectory", "C:") + "\mydoc.pdf";
PrintPDFFile(S);
end;You can then invoke this function from JavaScript or PHP or associate it with an event or a UI control.
Alternatively, ExeOutput apps provide a JavaScript extension, window.exportPDF(pdffilename), which allows you to export the window’s content as a PDF file. The pdffilename parameter specifies the full path and filename for the exported PDF.
For example:
<script language="javascript">
// Callback for the save dialog box.
// The 'content' parameter contains the full path for the new PDF file.
function DemoSavePDF(content) {
if (content === "") return;
window.exportPDF(content);
}
function exportpdf() {
// Run the HEScript function SavePDFDlgFile (defined in UserMain) to get the PDF filename.
exeoutput.GetHEScriptCom('hescript://UserMain.SavePDFDlgFile', DemoSavePDF);
}
</script>