Script to Change Width and Height of All Checkboxes in PDF Not Working
Hi everyone,
I’m working on a PDF form in Acrobat and trying to adjust the width and height of all checkboxes using JavaScript. I’ve written a script, but it doesn’t seem to be working on all checkboxes.
Here’s the script I’m using:
// Conversion: 0.12 inches = 8.64 points
var newSize = 8.64;
// Iterate through all the fields in the document
for (var i = 0; i < this.numFields; i++) {
// Get the field name
var fieldName = this.getNthFieldName(i);
// Get the field object
var field = this.getField(fieldName);
// Check if the field is a checkbox
if (field.type === "checkbox") {
// Get the current position of the checkbox
var rect = field.rect;
// Calculate the center of the checkbox
var centerX = (rect[0] + rect[2]) / 2; // Horizontal center (average of left and right)
var centerY = (rect[1] + rect[3]) / 2; // Vertical center (average of bottom and top)
// Calculate the new left, right, top, and bottom values
var newLeft = centerX - newSize / 2;
var newRight = centerX + newSize / 2;
var newBottom = centerY - newSize / 2;
var newTop = centerY + newSize / 2;
// Apply the new size while maintaining the center position
field.rect = [newLeft, newBottom, newRight, newTop];
}
}
app.alert("All checboxes changed to 0.12 inches")
Could anyone help me figure out what’s going wrong or suggest improvements to make this work for all checkboxes?
Thanks!
Prabu G
