Display Multiple Pages Image

Hello all,

I would like to display multi pages image at a section in my print template.
But I don’t know how to do.The image have 16 pages.The image file name get from data field and it may be a different image that have different pages.
I know how to create dynamic image but I don’t know how to display it.
How should I do ?

Thanks

1 Like

Is the Image file a Multi Page TIFF or is it a PDF?

I have not tested a multi page TIFF but this works for PDF for sure, just add ?page=2 at the end of your image path. To make it dynamic simply use a dynamic image script.

Hi, iBaldie

Thanks for your answer.

So, if I want to display all of the image file,I should get the image’s total page first and use 16 dynamic image script?

The image file is PDF.

I want the image’s page 1 display on document page 1,page 2 display on document page 2

Hi zoidsabcd,

You may test the below code which gets the number of pages in the PDF and dynamically create each page. It is assumed that the PDF is A4 (210x297mm)

var pdfResource = ‘file://C:/images/samplePDF.pdf’;
var numPages = resource(pdfResource).pages;

// reversed for loop so that the pages appear in the correct order
for(var i = numPages; i > 0; i–){
pdfResourcePage = pdfResource + ‘?page=’ + i;
results.after(‘<div class=“page” style="width: 210mm; height: 297mm; background-image: url(’ + pdfResourcePage + ‘); "></div>’);
}

// hide our placeholder
results.hide();

Regards,

Rod

Hi, Rod

Thanks a lot!

It works.

Hi zoidsabcd,

You may test the below code which gets the number of pages in the PDF and dynamically create each page. It is assumed that the PDF is A4 (210x297mm)

var pdfResource = ‘file://C:/images/samplePDF.pdf’;
var numPages = resource(pdfResource).pages;

// reversed for loop so that the pages appear in the correct order
for(var i = numPages; i > 0; i–){
pdfResourcePage = pdfResource + ‘?page=’ + i;
results.after(‘<div class=“page” style="width: 210mm; height: 297mm; background-image: url(’ + pdfResourcePage + ‘); "></div>’);
}

// hide our placeholder
results.hide();

Regards,

Rod