DISCLAIMER: The following method can only work if each PDF page is a distinct record. If some records have more than a single page, it won’t work.
- In the Pre-Processor step, create a Property named TotalPages with the following settings:
Scope: Entire data
Default value: 0
- In the Settings, set the Boundaries Trigger to On script
- In the Expression field, add the following code:
Now in your data mapping process, you just have to extract the data.properties.TotalPages value to a field, it will contain the total number of pages in the PDF.
NOTE: the code above can be adapted to work if each record has a fixed number of pages (for instance, if all records have 2 pages). But as stated earlier, it cannot work if you have a variable number of pages per record. In that case, you’d be better off counting the pages through a script in Workflow and passing the value to the DataMapper.