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

Acrobat DC Javascript custom dialogue help

New Here ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

  • I am a complete newbie to JavaScript and this is my first post. With the help of various snippets of script I have found on the web and Thom Parker's book "all about pdf stamps" I have created a custom dialogue to populate several text fields and tick boxes of a dynamic stamp. The stamp works well but it could be better. I would like the input fields on the custom dialogue to display default values rather than blank white space. I can get one field to display as I would like, but only the last of 7 fields does this. If I copy what I did in field 7 to the others it doesn't work for the others but field 7 does work. Can you help? I have 7 lines like this:
  • strField1: "", 
  • initialize: function(dialog) {
  • dialog.load({"fld1":this.strField1});
  • },
  • These lines are repeated with strField1 and fld1 replaced by  strField2 to strField7 and fld2 to fld7 followed by the following script:
  • commit:function(dialog) {
  • var data=dialog.store();
  • this.strField1=data["fld1"];
  • Again this is repeated for the other fields as before.
  • I changed strField7:"", to strField7:"something else", and it defaults to "something else" instead of white space and the stamp works whether the custom dialogue default value is left or it is typed over. But it only works with this last field. If I do exactly the same thing with the others I still get the blank white input box but no default. I hope this makes sense and somebody can help me with this.
TOPICS
Acrobat SDK and JavaScript

Views

1.5K

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 , May 19, 2020 May 19, 2020

You've over-complicated the code. Simply use this as the initialize function:

 

 

    initialize: function(dialog) {
        dialog.load({
			"fld1":"1",
			"fld2":"2",
			"fld3":"3",
			"fld4":"4",
			"fld5":"5",
			"fld6":"6",
			"fld7":"7"
		});
    },

 

Votes

Translate

Translate
Community Expert ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

You've over-complicated the code. Simply use this as the initialize function:

 

 

    initialize: function(dialog) {
        dialog.load({
			"fld1":"1",
			"fld2":"2",
			"fld3":"3",
			"fld4":"4",
			"fld5":"5",
			"fld6":"6",
			"fld7":"7"
		});
    },

 

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Try67 I cannot thank you enough. I am a complete novice to JavaScript and do not fully understand it as you can tell. I am surprised I got this far before getting stuck. But I have seen the help you have given others. The speed with which you replied was phenomenal and the solution spot on. Many thanks.

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Don't feel bad. Dialogs are one of the most complicated things one can do in Acrobat JS...

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

You'll find a drag and drop Dialog editor, and some tutorial vidoes, here:

https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm 

 

If you have questions about these things, you should email or message me.

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

Thank you Thom. Sometimes I find it hard to work things out for myself. I wouldn't have made it this far without your book and the help of both you and Try67. I greatly appreciate your help.

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 ,
May 19, 2020 May 19, 2020

Copy link to clipboard

Copied

LATEST

Thanks, Glad to help

 

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