How to refer to the Datamapped PDF in a Control Script

What is the syntax for referring to the DataMapped PDF resource? I see the “resource()” function, and I see elsewhere that there is a constant “DATAMAPPED_PDF” which can be used, for example, when setting the background of a Print Section. But the resource() command doesn’t recognized the constant.

I want to measure the size of the PDF being used as a data source and enable the correct Print Section based on size and/or orientation.

This script fails:

if(resource(DATAMAPPER_PDF,1).height>355)
{
merge.template.contexts.PRINT.sections[‘LegalPortrait’].background.source = BackgroundResource.DATAMAPPER_PDF;
}

In your datamapper, add two javascript fields;

Each of them is then set to: steps.currentPageHeight and steps.currentPageWidth.

Then you will be able to do your condition.