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

Net.HTTP.request - Return SQL or REST API Query Results to Acrobat Forms

Community Beginner ,
Sep 05, 2022 Sep 05, 2022

Copy link to clipboard

Copied

Using the most excellent code examples found on Thom Parker's www.pdfscripting.com site I created a PDF form that calculates a URL for a Net.HTTP.request to a PHP file that queries a MySQL database for a specific price.

 

The attached screenshot shows the Folder Level Automation script, the form, with results printed to the console for 3 queries with different sets of  parameters assembled from the form's drop-down meus. 

 

getremotedata.jpg

 

What is the best way to grab the value that is currently being written to the console and return it to a form field so it can be used in further calculations. 

 

Thom Parker's scripts and instructions can be found in the "Load Remote Data with HTTP" section in this post...

https://www.pdfscripting.com/members/Acquiring_Raw_File_Data.cfm#Scripts

 

If this is possible to do it opens up an extraordinary range of options for interacting with SQL databases and REST APIs. Just sayin'.

TOPICS
JavaScript , PDF forms

Views

233

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 Beginner ,
Mar 27, 2024 Mar 27, 2024

Copy link to clipboard

Copied

I modified my original approach and now have an extremely reliable way to extend Acrobat forms with PHP to enable securable real time interactions with SQL databases or REST APIs. If you are interested in this type functionality you can download and test using the demo form available at...

https://customdataservices.net/acrobat_forms_list.php

 

PDQformimage.jpgPDQformimage2.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 ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

This approach is limited by a few things.

1) It only works from a privileged location. Mostly suitable for automation scripting, not form scripting. 

2) It only works in the desktop Acrobat Pro and Reader.

3) Restricted in Reader unless the current document has special Form Rights that must be purchased from Adobe.  

 

 

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
Community Beginner ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

Hi Thom,

Thanks for your reply. I didn't run in to any of these issues in testing (but I am relatively new to Acrobat technologies).

 

1) It only works from a privileged location. Mostly suitable for automation scripting, not form scripting. 

- Not sure what you mean. You can download it where you'd like, open it, and accept the initial trust prompt.

 

2) It only works in the desktop Acrobat Pro and Reader.

- Excellent, bypasses many browser-related securtity issues.

 

3) Restricted in Reader unless the current document has special Form Rights that must be purchased from Adobe. 

- Not sure what you mean. Works great in Reader without additional purchases.

 

Can you clarify?

 

 

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 ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

Trusted operation depends on the user's settings. Try changing the "Security (advanced)" preferences and see how that affects the script behavior. In fact you'll notice the after you've clicked on the yellow bar "trust this document" button that the document shows up in the trused list in the preferences.  So there is a built-in way for the user to state they trust the document.  But this may not always be possible, just something to be aware of. 

 

Form Rights are listed in the Acrobat JS Reference and I remember this being a problem.  But the Reader restriction may have changed, its been some time since I've used this object.

  

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
Community Beginner ,
Mar 31, 2024 Mar 31, 2024

Copy link to clipboard

Copied

LATEST

Thank you for that clarification. My original goal was to find a way to help my company so, in our case, we would be deploying to worksations and laptops configured to our spec. 

 

One other interesting thing to consider is that posting query parameters to PHP scripts and returning the query results to the form doesn't require JavaScript be enabled (at least theoretically, I haven't actually tested).

 

Are there any Adobe staffers reading this post that can point out other potential problems for utilizing Acrobat forms this way? Any feedback would be greatly appreciated, we plan on deploying forms using this approach shortly.

 

Thanks!

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