I’m almost sure what I want is not accessible via a script. I will have ±100 PDF’s named like below but each name will be variable.
4900095 XXXXX YYYYY DDD_GGG AA CCCCCC to Widow or Spouse_excl. vol pensions PAID POLICY.pdf
The number in the beginning of the file name matches the data field SCHEME. I don’t want to rename the PDF to 4900095.pdf so that it works in my current script.
merge.template.contexts.PRINT.sections["Section 2"].background.source = BackgroundResource.RESOURCE_PDF;
merge.template.contexts.PRINT.sections["Section 2"].background.allPages = true;
var resourceUrl = 'images/' + record.fields.SCHEME + '.pdf';
merge.template.contexts.PRINT.sections["Section 2"].background.url = resourceUrl;
What would be ideal is if I could loop through ‘images/’ resource folder, get every image filename into an array, use said array with IF statement & Includes to match the SCHEME number in the beginning of the file name to the SCHEME field in the data mapper.
Answer is probably no, but it would be a great feature I think.
I know I can setup a Workflow process and rename said PDF’s but if this was possible… another step avoided is time saved