Skip to main content
Participating Frequently
December 21, 2022
Answered

how to change all radio button and check box size, style, and font size in multiple page

  • December 21, 2022
  • 1 reply
  • 1741 views

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?

This topic has been closed for replies.
Correct answer Thom Parker

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


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;
     }
}

 

1 reply

Thom Parker
Community Expert
Community Expert
December 21, 2022

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

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
December 22, 2022

thanks Thom, but i cant undestand, how to make it work to all the object

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
December 23, 2022

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


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;
     }
}

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often