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

Set a variable value in PDF from javascript

New Here ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

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

Views

3.3K

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

Copy link to clipboard

Copied

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

var a = 1;

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

 

 

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

Copy link to clipboard

Copied

What web browser does you use?

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

LATEST

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

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