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

Mirroring a field from an attached PDF using JS

Community Beginner ,
Mar 03, 2020 Mar 03, 2020

Hello all! 

 

I have a fillable form with an attached pdf file. Rather than the user having to enter the same information (i.e. name, title...etc.) Is it possible for the data fields to mirror each other from one PDF to the attached PDF? maybe using javascript? 

 

Thank you in advance! 

TOPICS
PDF forms
976
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 03, 2020 Mar 03, 2020

Yes, there are a few different ways to approach a solution.

If the scripts have to be on the PDF, then a script on the main doc can acquire field values from an attached file, or write values to an attached file. It doesn't work the other way around when you are doing this directly thru the doc objects because an embedded file doesn't know who it's parent is, or have the abilty to directly access it. 

But the main file can open an attachement PDF with

"Doc.openDataObject()". 

This opens the attached file as hidden. The user doesn't see it, but its visible to JavaScript for accessing the fields. 

Here's the reference entry:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

This type of scirpt best placed in a button on the main PDF.

 

Another method is to write data to a common location, where the other file can read it. This is not as easy as it used to be from a document script. But I still think there are some gobal objects that will work for his, such as the color object. Again this type of script is best placed in a button the user presses to update data.

 

 

 

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

View solution in original post

Translate
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 03, 2020 Mar 03, 2020

Yes, there are a few different ways to approach a solution.

If the scripts have to be on the PDF, then a script on the main doc can acquire field values from an attached file, or write values to an attached file. It doesn't work the other way around when you are doing this directly thru the doc objects because an embedded file doesn't know who it's parent is, or have the abilty to directly access it. 

But the main file can open an attachement PDF with

"Doc.openDataObject()". 

This opens the attached file as hidden. The user doesn't see it, but its visible to JavaScript for accessing the fields. 

Here's the reference entry:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

This type of scirpt best placed in a button on the main PDF.

 

Another method is to write data to a common location, where the other file can read it. This is not as easy as it used to be from a document script. But I still think there are some gobal objects that will work for his, such as the color object. Again this type of script is best placed in a button the user presses to update data.

 

 

 

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

Translate
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 Beginner ,
Mar 05, 2020 Mar 05, 2020
LATEST

Thank you so much! Thom! i"m gonna try this today. 

Translate
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