Skip to main content
Participant
February 15, 2023
Question

text file

  • February 15, 2023
  • 2 replies
  • 1418 views

Hello,

 

How can i read a text file opening a PDF to retrieve the number (text) and display it in a field ?

 

Thanks in advance

JC

This topic has been closed for replies.

2 replies

Participant
February 15, 2023

re,

Yes I need to get a value from a text file and put it into a field on existing PDF form..

 

but, I have in the PDF form and i would like that when opening it retrieves a number a put into field adn when saving it can increase the number in text file.

the PDF form must have an incremental number

 

Thanks

JC 

Thom Parker
Community Expert
Community Expert
February 15, 2023

From an Acrobat script, the contents of any file can be acquired with the util.readStreamFromFile() function.

Here's the reference entry:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#readfileintostream

 

It includes an example of reading a text file. 

 

Now the second part is parsing the text file format to get your number. How is this text formatted?

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
February 15, 2023

Please explain your workflow in detail. Are you converting a text file to PDF? or do you need to get a value from a text file and put it into a field on an existing PDF form?

 

 

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