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

Set the standard field format

Contributor ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Is it possible to customize the format of fields globally, like in a json file or something. We are prepairing a large number of forms with the following requiste

 

Date: dd.mm.yyyy

Number: 2 decimals:  1'234.56

Soc. security: 999.9999.9999.99

 

None of the other, build in formats are needed. 

Is it possible to set this standards per JavaScript?

 

TOPICS
JavaScript , PDF forms

Views

489

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 1 Correct answer

Community Expert , Mar 31, 2022 Mar 31, 2022

As mentioned, no, this is not possible in Acrobat.

You can use a script to do it, like this (paid-for) one I've developed (https://www.try67.com/tool/acrobat-apply-format-to-multiple-text-fields) which allows you to process fields based on their name, so if you name all your date field "Date_XXX", or all the SSN fields "SSN_", or something like that, you could specify that pattern to it and apply the desired Format setting to all those fields in a single process.

Votes

Translate

Translate
Community Expert ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

No, there is no easy way as in the browser based JavaScript that you are referring to. You can however write a script that goes through all fields and then sets the appropriate field scripts via the Field.setAction() function: https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%...

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Took me a little bit to find this, but apparently I wrote about how to do this seven years ago 🙂 

 

https://khkonsulting.com/2015/09/apply-standard-pdf-form-field-formattingkeystrokevalidation-events-...

 

 

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
Contributor ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

I'm doing that already for the fonts and checkmarks.

 

app.addMenuItem({
	cName: "Set Fields",
	cParent: "Edit",
	cExec: "set_all_fields();"
});


function set_all_fields()
{
    console.show();

	for(var n=0; n<this.numFields; n++) {
		var fieldName = this.getNthFieldName(n);
		var field = this.getField(fieldName);
		console.println(fieldName);
		switch(field.type) {
			case 'text' :
				field.textFont = 'Arial';
				field.textSize = 9;
				break;
			case 'checkbox':
				field.style = style.ch;
				break;
			default: console.println(field.type);
				break;
		}
	}
}

 

But unfortunately I don't know the names of the fields as Acrobat assigns its own fieldnames from the surrounding elements (randomly it seems).

 

But try67 suggestion might help me here. will try and post

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

As mentioned, no, this is not possible in Acrobat.

You can use a script to do it, like this (paid-for) one I've developed (https://www.try67.com/tool/acrobat-apply-format-to-multiple-text-fields) which allows you to process fields based on their name, so if you name all your date field "Date_XXX", or all the SSN fields "SSN_", or something like that, you could specify that pattern to it and apply the desired Format setting to all those fields in a single process.

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
Contributor ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

btw try67. we might be tempted to buy your Format tool. Does it still work on windows 10/11?

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

LATEST

Yes, it does!

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