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

Open and auto fill one PDF from another with a button

Explorer ,
Sep 16, 2019 Sep 16, 2019

Copy link to clipboard

Copied

I was unable to respond to my original post, so I'm recreating it because I'm still hoping to find some help with my problem...  I hope this is okay.

So, some history.

My original question was: Is it possible to create a fillable PDF form that open another PDF file and fills fields based on information from the first file.

The answer was a resounding yes with instructions on how to make it work.  The problem that I ran into was, while it worked on my computer - where I'm running Pro and another computer where we are running Standard - I am unable to make the button work on a terminal running Reader.

My company is running off a shared drive on the X drive on all computers, the files would be saved and held in this location for everyone in a particular department to access and use.

We attempted to open the files from the same location and we attempted to open the files from an attachment in the Master PDF.  All solutions worked on my computer (Pro) but I am unable to make it work on a computer running Reader.

It was suggested that I was having path issues, but there has yet to be a solve that works.  I am barely a lamen when it comes to Javascript.  Everything I've successfully accomplished has been with the help of users in this community or guesswork on my side (which has all been luck, let me tell you).

 

To start, I added a document level script to the secondary file that would open from the Master:

this.disclosed = true;

Then I created a button the Master file that would open the secondary file:

var targetPDF = app.openDoc("myContyract.pdf");

Then I added another button (I also added this script to the open button to make both scripts run simultaneously) to auto fill the fields that lined up:

targetPDF.getField("targetFieldName").value = this.getField("mySourceFieldName").value

 

When this worked on Pro but not on Reader, we made adjustments to the second script as follows:

var targetPDF = app.openDoc("myContyract.pdf", this);

& an attempt to open it as an attachment in the Master File:

var targetPDF = this.openDataObject("aContract.pdf");

& another attempt to open as a separate file in the same location as the Master file:

var targetPDF = app.openDoc({cPath:"PlatinumFields.pdf",oDoc:this});

 

All of these solutions worked perfectly with Pro and Standard, but on the Reader computer I keep getting the same error:

Untitled.png

 

Any help would be extremely appreciated!  And to those who have helped me already, I am enormously grateful.  This is just an attempt to get some fresh eyes on a problem that may have closed itself for some reason or another

TOPICS
Acrobat SDK and JavaScript

Views

3.8K

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 2 Correct answers

Community Expert , Sep 18, 2019 Sep 18, 2019

Please disregard my last post. I documented myself better now.

 

Refer to this link: 

https://superuser.com/questions/1034399/opening-a-pdf-attachment-with-an-in-document-link

 

it worked for me using the exmple provide in the link above  using this function:

 

this.exportDataObject({ cName: "yourfilenamehere.pdf", nLaunch: 2 });

 

That was it for me. 

 

See slides below:

 

1) IN ACROBAT DC,  ATTACH THE FILE YOU NEED TO BE INVOKED BY THE BUTTON JAVASCRIPT

 

2) THEN CREATE THE BUTTON

 

openattachmentbutton5.png

 

 

3) ADD THE SCRIPT PROVIDE

...

Votes

Translate

Translate
Community Expert , Mar 09, 2020 Mar 09, 2020

Hi,

 

I have been able to manage this in Adobe Reader DC, by using the commands above, but adding a "Document JavaScript" to the included document.

On the included document

  1. Select "JavaScript" tool
  2. From the options that appear select "Document JavaScript"
  3. Enter a title in the name field of the dialog that appears
  4. Click "Add"
  5. Select all the text in the new window and replace with "this.disclosed = true" ( without quotes)
  6. save file.

 

On the document that contains the included document add the i

...

Votes

Translate

Translate
Community Expert ,
Sep 17, 2019 Sep 17, 2019

Copy link to clipboard

Copied

In order to be able to use the form(s) in Reader DC I may suggest for you to try and save the file as a follows:

 

"File"---> "Save As Other" ---> "Reader Extended PDF"--->"Enable More Tools..."

 

This will allow your users to use your form in Reader (including older versions or PDF viewers) and be able to Fill&Sign, comment, print, and save a local copy of the form under a different filename. They will not be able to use the editing capabilities that you are trying to achieve (or have achieved) with Adobe Acrobat.

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
Explorer ,
Sep 18, 2019 Sep 18, 2019

Copy link to clipboard

Copied

The fields aren't inaccessible on Reader. The Javascript instructions aren't being allowed to work for the button that I've created. I can make it work on Pro and Standard, saved with extended tools, but it won't work with Reader...

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 ,
Sep 18, 2019 Sep 18, 2019

Copy link to clipboard

Copied

I read in another thread where Try67 asked the user where was he placing the code (i.e. custom calculating script, custom format script, validation script, java script action or a document script?)

 

Also, can you check if the fields that your script is invoking are not locked? (Right click on the field, select properties, uncheck the box if it is locked)

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 ,
Sep 18, 2019 Sep 18, 2019

Copy link to clipboard

Copied

Please disregard my last post. I documented myself better now.

 

Refer to this link: 

https://superuser.com/questions/1034399/opening-a-pdf-attachment-with-an-in-document-link

 

it worked for me using the exmple provide in the link above  using this function:

 

this.exportDataObject({ cName: "yourfilenamehere.pdf", nLaunch: 2 });

 

That was it for me. 

 

See slides below:

 

1) IN ACROBAT DC,  ATTACH THE FILE YOU NEED TO BE INVOKED BY THE BUTTON JAVASCRIPT

 

2) THEN CREATE THE BUTTON

 

openattachmentbutton5.png

 

 

3) ADD THE SCRIPT PROVIDED IN THE LINK ABOVE; ENSURE IT IS A MOUSE UP FUNCTION.

 

4) WHEN DONE WITH THIS PORCEED TO SAVE THIS FILE AS READER EXTENDED---MORE TOOLS

 

 

 

 

 

5) THE FOLLOWING SLIDES IS TO PROVE THAT THE BUTTON WITH THE SCRIPT WORKED IN ACROBAT READER

 

openattachmentbutton.png

 

 

openattachmentbutton2.png

 

WHEN I CLICK THE BUTTON IT OPENS A NEW TAB WITH THE ATTACHMENT THAT I'VE INCLUDED

 

openattachmentbutton3.png

 

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
Explorer ,
Sep 19, 2019 Sep 19, 2019

Copy link to clipboard

Copied

You are a god among men, sir! You have officially solved half of my problem. With your fix, my file opens in Reader. Huzzah!

 

Now, however, my fill script for taking the data from the master PDF to the (now) attached PDF is not seeing the file.  The script is not seeing the attached file as the target PDF...  I've attemtped a couple different things to try and make it work, but (no surprise, since I don't really know what I'm doing) I have had no success...

 

Suggestions on how to fix that?

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 ,
Sep 23, 2019 Sep 23, 2019

Copy link to clipboard

Copied

Hi,

 

I  have not forgotten your issue. I've been working on an idea that is taking me a little too long but I think it is worth waiting.

 

I've found documentation that may allow the java script button to lunch the contents of the field(s) that you want to be copied from the master file onto the clipboard (temporary memory) .

 

I am stuck now with how to make the opened attachment grab the field values that were copied to the clipboard to automatically populate the fields in the other form.

 

 I dont get this to work as expected my main workaround then would be to have a button in the attached form, so that when the form is launched the user clicks on that button and it copies the contents that are already loaded in the clipboard to the desired fields.

 

 

Have you been able to find a work around yet?

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
Explorer ,
Sep 24, 2019 Sep 24, 2019

Copy link to clipboard

Copied

I have not. 😞 But thank you for not forgetting about me!

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 ,
Mar 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Has this been figured out? I'm starting from scratch, but I'd like to do something similar. I'd like to create a fillable form with roughly 23 fields (that could be filled in Reader), that would allow me to select another PDF file (any one of 30 or so files) and fill it using the information I entered in the original fillable form.

 

I'm very new to this concept, and have never written a script before, so this may be a big task to take on, but I'm willing to give it a shot!

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 09, 2020 Mar 09, 2020

Copy link to clipboard

Copied

Hi,

 

I have been able to manage this in Adobe Reader DC, by using the commands above, but adding a "Document JavaScript" to the included document.

On the included document

  1. Select "JavaScript" tool
  2. From the options that appear select "Document JavaScript"
  3. Enter a title in the name field of the dialog that appears
  4. Click "Add"
  5. Select all the text in the new window and replace with "this.disclosed = true" ( without quotes)
  6. save file.

 

On the document that contains the included document add the included document and you should be able to access the fields using the following code

 

// this assumes you only had the main document open before hand
// and that the main document is not disclosed.
var newlyOpenedDoc = app.activeDocs[0];
// now you should be able to access the fields as normal using the variable above
newlyOpenedDoc.getField("fieldName").value = "Some Value";

 

The Main document is extended using the rights mentioned above.

Please see this shared document that shoud show it working.

 

https://documentcloud.adobe.com/link/track?uri=urn%3Aaaid%3Ascds%3AUS%3A45c7ea08-8455-424c-9086-57c6...

 

Hope this helps

 

Malcolm

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 ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Malcolm,

 

Where did you copy and paste the code you mentioned above to?

 

Jonathan

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 ,
Jun 18, 2020 Jun 18, 2020

Copy link to clipboard

Copied

LATEST

Hi,

 

It is a Document JavaScript, so if you search the tools for JavaScript, you should find Document JavaScript, select that and the code should be there.

 

Regards

 

Malcolm

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