Import from one PDF to another

New Here ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Good day 

 

I am trying to import data from one pdf to another. I am trying to use code to allow a button to open a popup window (launching finder for mac) and then allow selecting a file for reading and importing its text from fillable pdf fields returned from a customer. Once this pdf is selected I want to import certain fields to the new pdf. I appreciate the names of the fields bneed to be the same as those in the original pdf in order to do this. I have followed the code from previous posts but cannot get the button to do anything. similalry my code is not doing anything when I click the button. is someone able and willing to help it would be much appreciated. 

 

This is my code so far. 

 

Finder = Application("Finder")

Finder.activate()

 

delay(1)

systemEvents = Application('System Events')

Finder = systemEvents.Processes['Finder']

 

Finder.windows[0].splitterGroups[0].groups[0].buttons[0].click()

 

var app = Application.Finder()

app.includeStandardAdditions = true

function readFile(file){

//Convert the file to a string

var fileString = file.toString()

 

// Read the file and return its contents

return app.read(Path(fileString))

}

 

var file = app.chooseFile({

ofType: "pdf",

withPrompt:"Please select a text pdf to read:"

})

 

readFile(file)

// Result: "contents of the chosen file."

 

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

55

Likes

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
LEGEND ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

This code chooses a file and reads it. Then the info is thrown away, it does nothing else, and doesn't talk to Acrobat. Maybe there was more code once?

Likes

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
LEGEND ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

And... where did you PUT this code? How do you run it? It certainly can't be put on a button a PDF, Acrobat can't talk to Finder...

Likes

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
Adobe Community Professional ,
Jun 05, 2022 Jun 05, 2022

Copy link to clipboard

Copied

Check the Javascript console for errors.

Likes

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
Adobe Community Professional ,
Jun 06, 2022 Jun 06, 2022

Copy link to clipboard

Copied

LATEST

To be clear, the script you provided is not Acrobat JavaScript. It looks like an Mac system script. Since it is not related to Acrobat or PDF, it was probably not something you found on this forum. Perhaps you should post on the forum where you originally found the script. 

 

 

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

Likes

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