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

How do I copy a data field from one pdf to another and still have it working on reader?

Community Beginner ,
Feb 21, 2022 Feb 21, 2022

Hi, 

I have two pdf forms or better I have split a document into two seperate forms for easy use (so that I can keep resetting documentA and keep documentB. Now some fields that are in documentA need to be copied into documentB (not many only about 5 or 6). However this is not a  field where I can just copy it across. It will be filled with  text in documentA and then I would like the answer also to change/appear in pdf document B. 

I have read that you can do this with a script or/ and a button? 

So I put a button on documentA or a code on fieldA that I want to copy to documentB fieldB? And whats the code I would need, please?

TOPICS
Create PDFs , JavaScript , PDF forms
3.1K
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 ,
Feb 21, 2022 Feb 21, 2022

Why can't you copy-paste the filled fields?

Using shortcuts or the Edit menu.


Acrobate du PDF, InDesigner et Photoshopographe
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 ,
Feb 22, 2022 Feb 22, 2022

I would like to copy the data that is written into the form to appear in the other form in the same field. 

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 ,
Feb 22, 2022 Feb 22, 2022

Doing it automatically is quite tricky. What you can do, though, is use two buttons: One to save the data into a global variable and another to populate the fields from that variable.

Then you open file A, click button #1, switch to file B and click button #2, and the data will be copied over.

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 ,
Feb 22, 2022 Feb 22, 2022

There are many different ways to do this. But all techniques require a specially designed tool/script, or the JavaScript skills to create a tool/script. Do you have such skills?

 

One of the basic requirments of such a script is that there needs to be a way to map field names in one form to field names in another form. The simplest solution is to use the same field names. But the exact solution depends on your particular situation.

 

So how exactly do you want this to work?  Do you control the field names on the form? Do you want a button on the PDF to transfer data? Can you install a folder level script on the system where this will be used, or does it all have to happen from scripts on the document? Is this a one time transfer, or does the data need to be saved so it can be reused?

 

Here's some general discussion on Form data handling:

https://www.pdfscripting.com/public/Form-Data-Handling.cfm

 

For example, data transfer can be done quite easily with an Acrobat Automation Script, and made to work exactly the same on both Reader and Professional.

https://www.pdfscripting.com/public/Automating-Acrobat.cfm

 

It can also be done from scripts on the documents if both documents are "disclosed".

 

 

 

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 ,
Feb 24, 2022 Feb 24, 2022

Thank you for that information. I have added the two pdf Documents that I am trying to link. I would like to be able to type into Form "DocA" and when I press "Link to DocB" I would like the data from the red and the blue box (from DocA) to be copied or transferred into "DocB". Where would I need to put the java script for the data to be copied into DocB?

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 ,
Feb 24, 2022 Feb 24, 2022

So the steps in a script to directly copy data from one document to another, from a script on one of the documents are

 

1.  Get the document object of the other document. To do this the other document must be "disclosed", and have a well known name, title, or some other metadata property that will allow it to be identified by the script.  All disclosed documents are visible in the app.activeDocs array.   The document should already be open in Acrobat.

 

2. loop over all fields in the other document,

   3. if fields with the same name exist in both, then move the data.

 

Pretty simple in concept. To make this work, the form fields that will be copied on each PDF will need to be named the same, and each PDF needs this document level script 

 

this.disclosed = true;

 

 

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 Expert ,
Feb 24, 2022 Feb 24, 2022
LATEST

Or you could join the site and get this tool:

https://www.pdfscripting.com/public/Copy-Form-Data-Between-PDFs-Description.cfm

 

 

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