These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

External Data Access

irap
Registered: Aug 6 2008
Posts: 56

I'm just starting to get my feet wet with JavaScript. So if there's another source I should be looking at please let me know.

Is there a way to pass data into JaveScript? For example, adding a
page to an existing PDF file that contains both fixed text and variable
text. I don't want to use the dialog boxes.

My Product Information:
Acrobat Pro Extended 9.0, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You might want do describe in detail what you're trying to accomplish. I'm not sure what you mean by "variable text". By "dialog boxes", do you mean text form fields?

George
irap
Registered: Aug 6 2008
Posts: 56
By variable text I mean items such as author names, paper titles. etc.

In the context of JavaScript dialog boxes really means interactive input.

So overall the program would:
1. Open a PDF file
2. Add a page prior to the first page.
3. On the new page add some standard fixed text.
4. Add the appropriate variable text. Ideally the variable text comes from a file some where.

Hope this clarifies things.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
OK. You can do #1 and #2 with JavaScript. For #3, I'd suggest creating the page that contains the standard text and inserting that page in step #2. For step #4, JavaScript cannot write to the regular page contents, but it can create text annotations and/or form fields with text. Once you add the annotations/fields, you could then flatten the pages via JavaScript, which would convert the annotation/field text to regular page contents.

Are you looking to do this in a batch sequence, a custom menu item, or something else?

George
irap
Registered: Aug 6 2008
Posts: 56
We're looking to do this as simply as possible. I think batch processing might be the best way.

The text for the new page would be something like this (Text in CAPS is variable):

Notice
TITLE
AUTHOR
PUBLICATION

Standard text

Ideally I'd like to create a simple text file to populate the variable text fields. So how do I get the data from the file into the PDF? Based on your description it seems a form field would be the best way to do this? Is there a better way?

Ira
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
That's what I'd be inclined to do, so yeah, that's the best way. :^)

To get data into the PDF, there are a number of options. I would probably import an FDF file that contains the field data, but I'm a bit of an FDF nut. It's probably the easiest to set up. You can also use the doc.importTextData() JavaScript method (or any of the other doc.importXXX methods).

Another option that may be sufficient is to use the Report object to create a page to insert with the text you want, but you have less control over fonts and positioning.

George