OL Learn

Dynamic background images from PDF


We need to create letters using static text/template, customer data in csv and 1 to 5 pdf documents for each letter.

The challenge we have is to to construct a path to a pdf in order to upload dynamic background images from PDF.

As workaround we can load the pdfs in Designer resources, but that means a huge template file and lack of flexibility for future jobs as we need to reload pdfs of each job in Designer.

this is best done via the control script
see https://help.objectiflune.com/en/pres-connect-user-guide/2019.2/#designer/Scripting/Scripting_Print_Background.htm

We tried that and it works… but it’s not the preferred solution.
We need to merge thousands of pdfs that we receive from our customer, one for each letter. Loading them in Designer resources makes the template very large - 1GB and it’s dynamic, therefore for the next order we need to re-design it. Ideally we need to find a way that the pdfs are picked up from a given location using a file name pattern

That same method works with files stored locally on the disk. Please refer to this section on dynamic images to determine the syntax for a file on the disk:

For instance, this pulls a static image off of my desktop. You’d simply need to swap out the path and filename for something dynamic. :

var activeSection = merge.template.contexts.PRINT.sections['Section 1'];
activeSection.background.source = BackgroundResource.RESOURCE_PDF;
activeSection.background.url = "file:///c:/Users/Administrator/Desktop/Sample Images/BACK-F-LT.pdf";
activeSection.background.position = MediaPosition.ABSOLUTE;
activeSection.background.left = "10mm";
activeSection.background.top = "10mm";