page control by data input PDF portrait and landscape

Hello all

I have as data input PDF’s in portrait and also landscape format. How can I set a page switch in designer to assign the right print layout? As print layout I’ve created 2 pages, 1 as A4 portrait and the other as A4 landscape.

Thank you your input in advance

Best regards

Miro

Hi Miro,

You can achieve this using a control script.

Assuming that each multi-page PDF represents a single record, you can get each page Width and Height in the datamapper with the following commands:

add a field of type “Float” based on JavaScript and get the page width. Let’s name this field pageWidth:

steps.currentPageWidth;

Do the same for the page height. Let’s name the field for the current page height: pageHeight

steps.currentPageHeight;

Next, add a control script which will enable only the Portrait section if pageHeight < pageWidth and vice versa. In the below control script, ‘Landscape’ and ‘Portrait’ represent the names of the landscape and portrait sections respectively:

if (record.fields.pageWidth > record.fields.pageHeight) {
merge.context.sections[‘Landscape’].enabled = true;
merge.context.sections[‘Portrait’].enabled = false;
} else{
merge.context.sections[‘Landscape’].enabled = false;
merge.context.sections[‘Portrait’].enabled = true;
}

The result will only be visible once you generate the actual output since this is when the control script is executed.

Regards,

Rod

Hi Rod

Thank you for your input and support.

Best regards

Miro