Copy link to clipboard
Copied
i would like to change all radio button and check box size, style, and font size in multipel page
font = 12 , widht = 0.2 in, height = 0.2in, button style = check
is that any solution that can do that?
Copy link to clipboard
Copied
Loop over all the fields in the form to sort out the fields you want to change
var oFld;
for(var i=0;i<this.numFields;i++)
{
oFld = this.getField(this.getNthFieldName(i));
if(oFld.type == "checkbox")
{ // Set new check box parameters
}
else if(oFld.type == "radiobutton")
{ // Set new radio button parameters
}
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Here's a more functional set of code.
One of the problems that needs to be solved for this type of code is "How do you identify the specific fields that need to be changed". This code only uses the field type. But you may also need to use names or other characteristics.
var oFld,nCenterX, nCenterY;
// new width and height, These are 1/2 sizes because the code resizes the fields
// from the center.
var nHalfW = .2 * 36;
var nHalfH = .2 * 36;
for(var i=0;i<this.numFields;i++)
{
oFld = this.getField(this.getNthFieldName(i));
if((oFld.type == "checkbox") || (oFld.type == "radiobutton"))
{ // Set new radio button/checkbox parameters
// Find center
nCenterX = (oFld.rect[0] + oFld.rect[2])/2;
nCenterY = (oFld.rect[1] + oFld.rect[3])/2;
// Create new rectangle
oFld.rect = [nCenterX-nHalfW, nCenterY+nHalfH, nCenterX+nHalfW,nCenterY-nHalfH]
oFld.style = style.ch;
oFld.textSize = 12;
}
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
This can be done with a script.
Here's an article that shows how to change field properties with a script.
https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
thanks Thom, but i cant undestand, how to make it work to all the object
Copy link to clipboard
Copied
Loop over all the fields in the form to sort out the fields you want to change
var oFld;
for(var i=0;i<this.numFields;i++)
{
oFld = this.getField(this.getNthFieldName(i));
if(oFld.type == "checkbox")
{ // Set new check box parameters
}
else if(oFld.type == "radiobutton")
{ // Set new radio button parameters
}
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
var oFld;
for(var i=0;i<this.numFields;i++);
{
oFld = this.getField(this.getNthFieldName(i));
if(oFld.type == "checkbox");
{ oFld.size = "16";
}
else if(oFld.type == "radiobutton");
{ // Set new radio button parameters
}
}
SyntaxError: syntax error
1:Console:Exec
undefined
Copy link to clipboard
Copied
It is of course really important to use the Acrobat JavaScript reference for getting all the correct names for the field properties.
The syntax error is probably due to not selecting all the code.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Here's a more functional set of code.
One of the problems that needs to be solved for this type of code is "How do you identify the specific fields that need to be changed". This code only uses the field type. But you may also need to use names or other characteristics.
var oFld,nCenterX, nCenterY;
// new width and height, These are 1/2 sizes because the code resizes the fields
// from the center.
var nHalfW = .2 * 36;
var nHalfH = .2 * 36;
for(var i=0;i<this.numFields;i++)
{
oFld = this.getField(this.getNthFieldName(i));
if((oFld.type == "checkbox") || (oFld.type == "radiobutton"))
{ // Set new radio button/checkbox parameters
// Find center
nCenterX = (oFld.rect[0] + oFld.rect[2])/2;
nCenterY = (oFld.rect[1] + oFld.rect[3])/2;
// Create new rectangle
oFld.rect = [nCenterX-nHalfW, nCenterY+nHalfH, nCenterX+nHalfW,nCenterY-nHalfH]
oFld.style = style.ch;
oFld.textSize = 12;
}
}
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks Tom. its work

