Dynamically load multiple multi-page PDFs in Designer

Hello,

I have XML files which consist of 1 record each. Approximate structure of the XML file is as follow:

<Project>
<CaseNo> 1111</CaseNo>
<CaseStruct>XYZ</CaseStruct>
<files>
<file>
<id>0</id>
<pdfname></pdfname>
</file>
<file>
<id>1</id>
<pdfname>test1.pdf</pdfname>
</file>
<file>
<id>2</id>
<pdfname>test2.df</pdfname>
</file>
<file>
<id>3</id>
<pdfname>test3.pdf</pdfname>
</file>
</files>
</Project>

As you can see the detail table has severeal detail records with the pdfname field which points to the PDF files to call.

I also need to add logos and some dynamic text to each page of the final output. I guess I could do this this part with a master page?

How do I dynamically call and load all the multipage PDF from the record detail in my section?

Many thanks in advance?

Steve

  • Create one section
  • Use a control script to clone the section as many times as there are records in the detail table
  • Apply a dynamic pdf background to each clone.

Below is the control script.

var printSections = merge.template.contexts.PRINT.sections;
merge.template.contexts.PRINT.sections[“Section 1”].enabled = false;

var numClones = record.tables[‘detail’].length;
var rootFolder= record.fields.rootFolder; //C://OLForums//156223//
var subDir= record.fields.CaseNo;
var pdfName;
for( var i = 0; i < numClones; i++){
pdfName= record.tables.detail[i].fields.pdfName;
addBackground(pdfName);
}

function addBackground(pdfName){

var resourceUrl = 'file:///' + rootFolder + subDir + '//' + pdfName;
//  C://OLForums//156223//1111//
var clone = printSections["Section 1"].clone();
clone.name = "clone_" + i;
clone.background.source= BackgroundResource.RESOURCE_PDF;
clone.background.url = resourceUrl;
clone.enabled = true;
printSections["Section 1"].addAfter(clone);

}

It works perfectly Rod. Thank you very much.

@Rod, is there any way to put barcodes with page numbers on every second page of a PDF placed using your script? These would need to reset per record.