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

Text from Excel to PDF via Script

New Here ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

Dear All,

is it possible to add text automatically to a pdf from a excel worksheet?

 

 

In this case, i would like to add "XCKA-1P" to the PDF.


Thanks in advance!

 

PDF:

2022-08-13 13_12_13-2022-08-13 13_07_05-15-8.pdf - Master PDF Editor.jpg - IrfanView (Zoom_ 1046 x 1.jpg

 

And Excel:

 

2022-08-13 13_07_27-15-8.xls  -  Compatibility Mode - Excel.jpg

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

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 ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

A script would have to find the name on each PDF page, compare it to the XLS Column A, and then add a text field to the PDF Page with the according data from column C.

 

In the example, the PDF page with the name "Ute Schmidt" would get a text field with "XCKA-1P"

The PDF page with "Gitta Lippold" would get a text field with "GBAD-1K"

 

and so on.

 

The text field can be anywhere on the PDF file in a free area.

 

Lastly the script should save and close the PDF file.

 

Again, thank you!

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 ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

A script can't read data from an Excel file. It might be able to do it if the file was saved as a plain-text file, though.

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 ,
Aug 13, 2022 Aug 13, 2022

Copy link to clipboard

Copied

yes, the excel file can easily be converted to text.

 

 

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

In that case you can use the readFileIntoStream method of the util object to read its contents to a Stream object, then the stringFromStream method of the same object to convert it to a String, and then parse it like any other String object in JS to get the info you need from it.

Note that the first method requires a privileged context if you want to specify the file-path of the file to read to it. Otherwise, you'll be prompted to select it manually each time you run the script.

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

sounds good. but is there any help on how to do this? i now how to do VBA macros in Excel but in Acrobat i have really no idea

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 ,
Aug 14, 2022 Aug 14, 2022

Copy link to clipboard

Copied

i am attaching all files, as well as an example (jpg)

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 ,
Aug 15, 2022 Aug 15, 2022

Copy link to clipboard

Copied

LATEST

You'll find scripts and tools here for importing Excel data into Acrobat, but they are not free. 

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

 

 

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

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