• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

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

New Here ,
Dec 21, 2022 Dec 21, 2022

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?

TOPICS
Edit and convert PDFs , JavaScript , PDF forms

Views

271

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Dec 21, 2022 Dec 21, 2022

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

Votes

Translate

Translate
Community Expert , Dec 22, 2022 Dec 22, 2022

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 =
...

Votes

Translate

Translate
Community Expert ,
Dec 21, 2022 Dec 21, 2022

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

 

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

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
     }
}
Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 21, 2022 Dec 21, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2022 Dec 22, 2022

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. 

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#field-propertie...

 

The syntax error is probably due to not selecting all the code.  

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 22, 2022 Dec 22, 2022

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

 

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2022 Dec 22, 2022

Copy link to clipboard

Copied

LATEST

Thanks Tom. its work

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines