I have an HTML snippet that is used as a global footer across multiple print sections.
Within this HTML snippet is a barcode with a different value based upon the print section that is calling the snippet.
For example:
Section 1 has a barcode value of ‘PINS’
Section 2 has a barcode value of ‘FACE’
If I create a Text Script that sets the value of the barcode, the Text Script evaluates before the print sections load and the barcode value is the same between Section 1 and Section 2.
For example, if the barcode has a div id = “Code39Barcode” and the following Text Script is set:
Section 1 and Section 2 have a barcode of ‘PINS’.
I tried creating an individual .js file for each section and called it in the ‘Print Section Properties > Includes’ section to change the barcode, but, it just replaced the barcode with the text ‘PINS’.
There are multiple ways to achieve that. Here are some techniques:
Section selector
Create two scripts. Create one for each section and set the respective barcode value. Change the selector for each script so it includes the section name (section is an attribute of the underlying HTML). Eg.:
[section='Section 1'] #Code39Barcode
Section name in script
Check the section name in the script and use that in an if statement.
Execution scope
Create two scripts. Create one for each section and set the respective barcode value. Subequently add two folders to the Scripts panel. Again, one for each section. Place the scripts in the corresponding folder. Right mouse click the first folder and select Properties, the Script Folder Properties dialog appears. Set the execution scope to the respective section (e.g. disabling the other sections and master pages). Click OK to store the value. Repeat these steps for the other folder.
I would say please make sure that you are changing the value of a QR code by a Standard Script rather than a Post Pagination Script because I assume that you cannot change the value of a QR code by a Post Pagination Script and because I am not able to reproduce the issue when I apply the shared JavaScript code to a Standard Script instead.
Hi @Marten, I need to do it in post because I need access to this.info().pageNo, as I know of no other way of accessing the section page number in Designer - unless there exists an equivalent of {#} in JS that I don’t know about.
A option you might concider in this case is to add the QR barcode element to each page by making use of a Job Creation Preset and Output Creation Preset. To do this you have to execute the following steps:
Job Creation Preset
Create a new Job Creation Preset via: Connect Designer > File > Print Presets > Job Creation Settings…
Check the option “include meta data” in the Configuration Selection window.
Click on “Next” and go inside the Meta Data Options window to the Document Tags tab.
Add the record fields “strBookletNo” and “ID” to the Documents Tags tab by clicking on the “plus” button on the right side of the list of Document Tags, select the option “Add field meta data”, select the record fields “strBookletNo” and “ID” and click on “OK”.
Save the Job Creation Preset file by clicking on the “Finish” button.
Output Creation Preset
Create a new Output Creation Preset via: Connect Designer > File > Print Presets > Output Creation Settings…
Select the just created Job Creation Preset file in the Configuration Name select option on the bottom side of the Configuration Selection window.
Click on “Next” and check the “Add additional content” option in the Print Options window.
Click on “Next” and click on the “plus” button on the right side of the list of Additional Content in the Additional Content window and select the option: Barcode > QR Code.
Click in the Additional Barcode wizard on the “plus” button on the right side of the Text input field, which you can find at the bottom of the Additional Barcode wizard, and select the option “Document meta data fields”. Here you have the option to add the record fields one by one to the Text input field. You also have the option to add the page number to the Text input field (“${page.nr}”). To be able to do this you have to select the option “Info Field” > “Document page number” instead of the option “Document meta data fields”.
The result in the Text input field will become something like:
The only thing that you will have to test is if you can use the methods “toString” and “padStart” in the Text input field. In case you can use these methods inside the Text input field then the result in the Text input field will become something like:
Thank you @Marten - managed to get the QR codes on.
Now the second stage. In output creation I use imposition as booklet and face down sequence, so that the first page of the PDF is the innermost spread. On the right hand side, in the bleed area, I need to add a barcode and human readable string with an ID ending in sheet number and sheet count of the output (so for a 40pp book it should go 0110 on page 1 of the imposed output, 0210 on page 3, 0310 on 5 etc.). Except variables relating to sheets are using the pre-imposition sheet numbers: