The Post Population Script is called when the field is tagged to a frame during the final stage of population. The script receives a series of arguments that vary depending on whether the Scripting module is installed. Without the Scripting module, only two arguments are passed:
arguments[0] : The item being populated.
arguments[1] : The document object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Get the target frame frame = arguments[0]; // Get the document var doc = arguments[1]; // Set stroke color to Red frame.strokeColor = doc.swatches.itemByName("Red"); // Set stroke weight to 5 points frame.strokeWeight = 5; // Optional: Set stroke alignment (e.g. centered, inside, or back) frame.strokeAlignment = StrokeAlignment.CENTER_ALIGNMENT; // or .BACK, .INSIDE_ALIGNMENT |
With the Scripting Module installed, an additional two parameters are passed that can be used to extend the behaviour:
arguments[2] : The DataSource object.
arguments[3] : The Record object.
1 2 3 4 | var frame = arguments[0]; var record = arguments[3]; var stroke = record.fields.item("stroke weight") frame.strokeWeight = stroke.fieldContent; |
For more complex scripts, a script file can be placed in the data sources Scripts folder, and be referenced with a single include:
1 | #include "applycolour.jsx" |
Example script to scale a barcode, so it is has less whitespace around it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | var frame = arguments[0]; if (frame.pageItems.length > 0) { var innerFrame = frame.pageItems[0]; var bounds = innerFrame.geometricBounds; var currentWidth = bounds[3] - bounds[1]; // right - left var currentHeight = bounds[2] - bounds[0]; // bottom - top // Set the resize percentage (e.g., 120% for 20% bigger) var resizeFactor = 120 / 100; // Calculate new width and height based on the percentage var newWidth = currentWidth * resizeFactor; var newHeight = currentHeight * resizeFactor; var newBottom = bounds[0] + newHeight; var newRight = bounds[1] + newWidth; // Optional: center the image within the frame innerFrame.geometricBounds = [bounds[0], bounds[1], newBottom, newRight]; frame.fit(FitOptions.CENTER_CONTENT); } |