Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > PDF API

PDF Parameters

Scroll Prev Next More

Description

PDF parameters (params) are objects that determine how a PDF file is created.

 

PDF parameters are used in:

Runner.PDF.open

Runner.PDF.download

AJAX helper object: ajax.addPDF

 

All individual parameters are optional and are used only if specified. Otherwise, the default values are used.

 

You can specify any of the parameters by adding the following expression to your code.

Example

Create and download View page for the table "cars" with an Id of 5.

 

var params = {
 table: 'cars',
 page: 'view',
 pageType: 'view',
 keys: ['5']
}
Runner.PDF.download( params );

Data source parameters

table {string} 

Defines the table or report name to be converted to PDF.

Default value: current table/report.

Note: when creating a PDF file based on a different table than the one where the button is placed, you must specify the pageType parameter as well.

For example, when you want to create a PDF based on the "Orders" table from a button added to the "Customers" page:

 

var params = {
table: 'Orders',
page: 'print',
pageType: 'print'
}

 

pageType {string}

Defines the page type to be converted to PDF. This parameter becomes mandatory when the table parameter is specified.

Possible values are view and print:

view - View page;

print - Print page.

 

Default values:

print in reports;

view if the code is run on the View page;

print in all other cases.

 

page {string}

Defines the page name. Default value corresponds to the default page specified with the pageType.

scope {number}

Defines which data should be added to the PDF file. This setting applies to the Print page only.

Possible values:

0 - this page only. Creates a PDF file with the same data you see on the current page. On the List page, this option uses settings selected on the Print panel;

1 - all pages;

2 - selection only. When on the List page, only the selected records are added to the PDF file.

 

Default value: 0.

split {number}

Specifies how to split the PDF file into pages. This setting applies to the Print page only.

Possible values:

0 - auto, fit as many records as possible into the page;

1 - fixed number of records. Specify how many records on each page you want to see by using the records option;

2 - read number of records from the printer panel.

 

Default value: 0

records {number}

When the split option value is 1 (fixed), this option determines how many records to show on each page.

Default value: 10

selection {array or arrays}

Defines which records to add to the PDF file. The value should be an array of arrays even if there is only one key field in the table: [ [1], [2], [10] ].

No default value.

keys {array}

When creating a PDF based on the View page, specify key field values here. This parameter is not needed when the code is added to the same View page.

No default value.

Example:

var params = {
pageType: 'view',
keys: ['10']
}

Document appearance options

filename {string}

Sets the PDF file name. Default value: 'file.pdf'.

orientation {string}

Sets the PDF orientation.

Possible values:

portrait

landscape

 

Default value:  portrait.

scale: {number}

Makes the PDF document bigger or smaller. The 50 scale makes it 2 times smaller than the default 100 scale. You can adjust this parameter as you see fit. Default value: 100.

backgroundImage: {string}

Sets an image as the background of the PDF file. Specify the filename here. The file is read from the <application root>/images directory.

For example, if you specify:

backgroundImage: 'pdf/logo.jpg'

 

Then image/pdf/logo.jpg is used.

Only PNG and JPEG images can be added to PDF document. The image is resized to fit to the entire document page.

No default value.

backgroundOpacity: {number}

Defines the opacity level, or how transparent the background image should be.

Possible values range from 100 (fully opaque) to 0 (fully transparent). Default value: 100.

See also:

Example: Creating PDF from all selected records except the first one

Example: How to email selected records as separate PDF files

PDF view settings

About PDF API