Create pad from PDF document

From a PDF document (typically a 1 page), I’m trying to create a PDF with x number of pages and applying a number (padded with leading zeros).

Original PDF - One page

If x = 5, then Output PDF is 5 pages and each have a number 00001 through 00005 applied.

I don’t know if this is correct or not, but in the datamapper.
The QTY is passed to the datamapper via a parameter.

I manually created a table Padding and index field Pvalue.

image

Then in my extraction, I added a SetPvalue JavaScript field with this code.

var count = 1;
for (var i = record.tables.Padding.length; i < record.fields.Qty; i++) {
    var paddedCount = count.toString().padStart(5, '0');
    logger.info("paddedCount: " + paddedCount);
    record.tables.Padding.addRow({"Pvalue": paddedCount});
    count++;
}

In the template, I cloned the section and inserted the handlebar removing the detail table reference.

This appears to work for 1-page PDF document, but for a 2-page document, I get all the page 1’s and then all the page 2’s. The sequence number is correct, but the order is wrong.
PadDoc.pdf (45.8 KB)

I would like to get all the pages of the original PDF together. Such as

  • Clone 1 Page 1
  • Clone 1 Page 2
  • Clone 2 Page 1
  • Clone 2 Page 2
  • Clone 3 Page 1
  • Clone 3 Page 2

Output is grouped by top-level records, so if you want to keep the PDF pages together they need to be part of the same top-level record.

Based on your attachments I think in the data mapper the Trigger under Settings > Boundaries is set to “On page” (the default). Try setting it to “On all pages” instead.

Yes, this worked. I missed the boundaries because I was too focused in the template. Also moved the stamp from the segment to the master page because I need the number stamped on every page.