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

Set a variable value in PDF from javascript

New Here ,
Nov 17, 2020 Nov 17, 2020

Hello everyone,

 

need to set a variable value in a PDF from Javascript.

How can i set a variabile in a PDF, using Javascript or Java?

 

There's away to do this?

 

Kind regards

 

TOPICS
PDF forms
3.8K
Translate
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 ,
Nov 17, 2020 Nov 17, 2020

Acrobat uses Javascript. You set the value of a variable like this:

var a = 1;

Translate
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 ,
Nov 17, 2020 Nov 17, 2020

It might be that you mean something different by variable than we do. Please explain your needs in more detail. Acrobat supports JavaScript, and not Java.

Translate
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 ,
Nov 18, 2020 Nov 18, 2020

Thank you all for the reply.

 

I know that Acrobat uses Javascript.

I would like to know if there's a way to access the internal Javascript of the document and set a global variable (ex. a boolean) to true or false. This from a web page that have is own javascript that load or open the PDF or from a Java classes that, again,  load or open the PDF. This is needed to make the PDF "aware" that it is working in a certain context and, by conseguence, the internal PDF Javascript  will behave differently.
Maybe this not is the best route to follow, but i'm open to suggestions 🙂

More generally, i do i communicate from the client side Javascript (the scrips that are in a web page) or from a Java class with the internal code of the PDF?

 

I hope i have explained better my needs.

 

Thank you all

 

 

Translate
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 ,
Nov 18, 2020 Nov 18, 2020

What web browser does you use?

Translate
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 ,
Nov 18, 2020 Nov 18, 2020

Since each browser has its own PDF viewer, with its own form functions (often not working right) and perhaps nonexistent JavaScript, the whole idea of using PDF forms in a browser is very dubious indeed. PDF has been killed by its own success, because browser Acrobat form/JavaScript support wasn't something done properly by the browser makers. I suggest abandoning PDF in your solution completely, or doing server-side manipulation instead.

Translate
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 ,
Nov 17, 2020 Nov 17, 2020

Read This:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

 

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

Translate
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 ,
Dec 02, 2020 Dec 02, 2020
LATEST

Thank you all for the reply. I've got precious informations.

Translate
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