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

Fillable form + javascript after filled in

New Here ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

I created my own fillable form and I am having the data filled into the PDF dynamically through the browser. I added some javascript in the PDF field below because I would like to tell it when a bullet point is needed. The problem is that no matter where I place this javascript it doesn't seem to execute after dynamically filling the form. I tested it using "preview" in acrobat, and when I type in my own text, it works fine with the onchange event. But again when the text area is filled in dynamically through my web code, it doesn't work. Am I placing my javscript in the wrong spot? I tried placing the javascript in the below areas and none of them worked:
1. properties > format tab > Custom > Custom format script

2. properties > format tab > Custom > Custom format script

if(event.value != "") {

event.value = event.value.replace(/{bullet}/g, "\u2022");

}

Is there another place I'm missing for when your form is dynamically filled + flattend from server code for a web page?

 

TOPICS
JavaScript , PDF forms

Views

554

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 ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

Correction:

1. properties > format tab > Custom > Custom format script

2. properties > format tab > Custom > Custom keystroke script (this is the 2nd area I tried to place my script)

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 ,
Aug 12, 2021 Aug 12, 2021

Copy link to clipboard

Copied

It's possible the way you're filling in the data doesn't trigger any events, especially not if it's done in the browser.

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 ,
Oct 30, 2021 Oct 30, 2021

Copy link to clipboard

Copied

Did you come up with any solution to this issue? I'm in the exact same boat and my client is asking for formatting that is not possible unless I use custom formatting. It does not trigger when the data is suppiled dynamically. Please let me know if you found a solution! 

My scenario is I'm using a plug-in that maps Gravity Forms fields to the supplied PDF. It uses the formatting of the fields int he PDF to display the data in the PDF - and this works great as long as I use the pre-supplied formating options in Acrobat. If I need to use custom, the Javascript does not fire. Is there any way around this? 

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 ,
Oct 31, 2021 Oct 31, 2021

Copy link to clipboard

Copied

LATEST

You can embed a script in the file that re-applies the values of all the fields when it is opened, which will cause the Format scripts to be triggered. You can use this code to do it:

 

for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.type=="button" || f.type=="signature") continue;
	var oldValue = f.valueAsString;
	if (oldValue!=f.defaultValue) {
		f.value = f.defaultValue;
		f.value = oldValue;
	}
}
this.dirty = false;

 

Note that this will cause a delay when opening the file, though.

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