Skip to main content

Exporting Widgets

Using Facilio script, you can export any connected app widget as PDF or screenshot with customizable options.

Export as PDF#

new NameSpace("connectedApp").exportAsPDF(fileName, connectedAppLinkName, widgetLinkName, pdfOptions, context) - is used to export any connected app widget as PDF.


Params

ParamDescription
fileNameFile name of the exported pdf to be saved
connectedAppLinkNameUnique link name of the connected app
widgetLinkNameUnique link name of the widget to export
pdfOptions(Optional) To customize the pdf appearance, refer to PDF options.
context(Optional) To pass any data to the widget. It can be accessible via app.getContext() function from inside widget.

PDF Options

PropertyTypeDescriptionDefault
formatstring(Optional)
Letter: 8.5in x 11in
Legal: 8.5in x 14in
Tabloid: 11in x 17in
Ledger: 17in x 11in
A0: 33.1in x 46.8in
A1: 23.4in x 33.1in
A2: 16.54in x 23.4in
A3: 11.7in x 16.54in
A4: 8.27in x 11.7in
A5: 5.83in x 8.27in
A6: 4.13in x 5.83in
letter
headerTemplate?string(Optional) HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:

date - formatted print date
title - document title
url - document location
pageNumber - current page number.
totalPages - total pages in the document
footerTemplate?string(Optional) HTML template for the print footer. Should be valid HTML with the following classes used to inject values into them:

date - formatted print date
title - document title
url - document location
pageNumber - current page number.
totalPages - total pages in the document
width?string/number(Optional) Sets the width of paper. You can pass in a number or a string with a unit.
height?string/number(Optional) Sets the height of paper. You can pass in a number or a string with a unit.
landscape?boolean(Optional) Whether to print in landscape orientation.false
marginTopnumber(Optional) Set the PDF top margin.no margins are set.
marginBottomnumber(Optional) Set the PDF bottom margin.no margins are set.
marginLeftnumber(Optional) Set the PDF left margin.no margins are set.
marginRightnumber(Optional) Set the PDF right margin.no margins are set.
omitBackground?boolean(Optional) Hides default white background and allows generating pdfs with transparency.
printBackground?boolean(Optional) Set to true to print background graphics.false
pageRanges?string(Optional) Paper ranges to print, e.g. 1-5, 8, 11-13.The empty string, which means all pages are printed.
scale?number(Optional) Scales the rendering of the web page. Amount must be between 0.1 and 2.1

Example

pdfOptions = {};pdfOptions.format =A3;
context = {};context.data = 123;
fileId = new NameSpace("connectedApp").exportAsPDF("widget.pdf", "connectedapp", "workorder_report", pdfOptions, context);
log fileId;

Export as Image#

new NameSpace("connectedApp").exportAsImage(fileName, connectedAppLinkName, widgetLinkName, screenshotOptions, context) - is used to export any connected app widget as an image.


Params:


ParamDescription
fileNameFile name of the exported pdf to be saved
connectedAppLinkNameUnique link name of the connected app
widgetLinkNameUnique link name of the widget to export
screenshotOptions(Optional) To customize the screenshot appearance, refer to Screenshot options.
context(Optional) To pass any data to the widget. It can be accessible via app.getContext() function from inside widget.

Screenshot Options:

PropertyTypeDescriptionDefault
selector?string(Optional) If you want to screenshot a particular element, you can pass a selector of the element.
format?string(Optional) Format of the screenshot.

png / jpeg / webp
png
omitBackground?boolean(Optional) Hides default white background and allows generating pdfs with transparency.
quality?number(Optional) Quality of the image, between 0-100. Not applicable to png images.

Example

screenshotOptions = {};screenshotOptions.fullPage = true;screenshotOptions.format = "jpeg";
context = {};context.data = 1244;
fileId= new NameSpace("connectedApp").exportAsImage("widget.jpeg", "connectedapp", "qrcode", screenshotOptions, context);
log fileId;