GeneratePDF (open)

Generate a PDF from a witty record

Syntax

LOADLIB "mod::system/lib/printer.whlib";

RECORD FUNCTION GeneratePDF(RECORD data, RECORD options)

Parameters

RECORD data

Witty data

RECORD options

Options

BOOLEAN debug

Enable debug mode

INTEGER delay

How much milliseconds to wait after setting the url before taking a screenshot

BOOLEAN displayheaderfooter

Display header and footer. Defaults to FALSE

filename

Output filename, will be genrated from the wittypath if not set

STRING footertemplate

Header template HTML code

getsource

Get a full dump of the data that will be used for the PDF. Used for debugging, may be removed in the future

STRING headertemplate

Header template HTML code

STRING invokeifdone

Function to invoke when rendering is done

RECORD margin

Page marginn (eg [ top := "0.5cm", bottom := "0.5cm", left := "1cm", right := "1cm" ]). Defaults to no margins

STRING media

Media to use - 'screen' or 'print' (default)

pdfengine

PDF Engine to use. 'chrome' (default)

printbackground

Print backgrounds too? (defaults to true)

INTEGER timeout

Timeout (in milliseconds) for PDF generation. Defaults to 30 seconds

wittypath

Path to witty template to use. If not set but the data contains a 'wittypath' variable, that one is used instead

Return value

RECORD

Wrapped file containing the PDF (or ZIP, if getsource is used). if 'getlog' is used, the wrapped file wil be in the "PDF" member

Description

Header and footer templates can use <span class="pageNumber"></span> and <span class="totalPages"></span> to show the page number and total number of pages respectively, but due to a Chrome limitation these are only shown if you also set the page margins to not intersect with these elements