Need to add a barcode including a pagnumber on each page in a pdf.
I have made datamapper, witch is not extraction anything in the pdf, except for the workflow variables I need.
Tried to ad an extraction step in the datamapper where pagenumber was steps.currentPage;
But the value always retur 1 - if there is 23 pages in the pdf, I get 23 records but the valus is always 1.
Is there a way to get the current page in the template ? - A page number can be set in by {#} - but is there a javascript which does the same?.
Need the barcode to be a unik guid + the page number
Tried comething like this in a script:
var Guid, NovoBarcode, PageNumber, result = “”;
PageNumber = ???
Guid = record.fields[“Guid”];
NovoBarcode = Guid + PageNumber; if (NovoBarcode !== “”) result += NovoBarcode;
results.html(NovoBarcode);
You have probably set your Record boundary trigger to be on each 1 page. So you will have as many records as there are pages in your PDF.
In this case, steps.currentPage returns the current page where the current position is located inside the current record. That’s why you always get 1.
If you aren’t extracting anything and that you aren’t adding pages to the PDf in the Designer as you say, you could use record.index; instead.
An alternative way, would be to set your trigger for the record boundary to All Pages in the Data Mapper and end up with 1 record per PDF regardless of the number of pages, then add your barcode in the Output Creation settings> Add Additional Content > Barcode and OMR Marks tab. You would get the current page number with: ${page.nr}
The list of variables available in the output preset is available here:
Like Rod said. Add and extract field to your data mapper. Change the fields Mode to JavaScript and type in the box
record.index;
That will get you the current page number stored in a field that can be used in a script to combine it to other fields and added to the barcode. or use the presets as suggested.