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

Populating pdf form using flask API

Participant ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

Hey Everyone,

 

I have data in a flask API that I want users to load into their custom pdf forms. My problem is finding documentation on how to approach this. 

 

My idea is that I have the user run javascript from the pdf (hit a button); have them enter a # in an app.alert window and then use the entered # for a HTTP GET request to flask which will then show the data. 

 

Which is where my problems start on how to best set this up, I've found the following code on the forums here which I hoped to utilize.

 

var url:String = "wwvv. URL GOES HERE/Script?number=007";
var importer:URLLoader = new URLLoader(new URLRequest(url));
importer.addEventListener(Event.COMPLETE, onFileLoaded);
function onFileLoaded(e:Event):void
{
    var importer:URLLoader = e.target as URLImporter;
    var importedVersionText:String = importer.data;
    dataImported_txt.text=loadedVersionText;
}
 
My questions boils down to the following:
  1. What is the best (data-)format to hand fielddata to a form. 

 

Any and all tips (including comments on the above script) on what to read/what way to approach this would be more than welcome.

 

Thank you in advance for any trouble to be taken.

TOPICS
Acrobat SDK and JavaScript

Views

577

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
Participant ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

It's a shame I cannot edit the post cause I've abandoned the example script.

 

I've got the flask side of things to be able to output in XML / json where needed but having difficulties (googling / adobe documentation) discovering how to get the button magic in the form to work.

 

Am I wrong in thinking this should be a relatively common approach to getting data in a form?

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
Participant ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

In the Developing Acrobat Applications Using JavaScript documentation it only says: (which I dont think says anything about importing form data.. so the title seems odd to me)

 

I'll keep lookiing for the right direction to take this in.. the backup route will be to generate the pdf serverside and just mail it. But I'd prefer being able to load the data into the form using the REST api

 

Importing and exporting form data
Form data can be exported to a separate file, which can then be sent using email or over the web. When
doing this, save either to Forms Data Format (FDF) or XML-based FDF (XFDF). This creates an export file
much smaller than the original PDF file. To programmatically save your data in one of these formats use
the Doc object methods exportAsFDF and exportAsXFDF.
On the server-side, use the FDF Toolkit to read the FDF data, or use a XML parser or library to read the XFDF
data
Note that Acrobat DC forms support the FDF, XFDF, tab-delimited text, and XML formats, and that XML
forms support XML and XDP formats.

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 ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

The script seemed to be using browser JavaScript methods. There are strict limits on PDF form's abilities to contact the internet, since it can be embedded in downloaded PDFs.

 

I think the reference to FDF/XFDF is basically obsolete, because people now display PDFs in browsers which don't support that - and don't support PDF JavaScript well either. I suggest working with an HTML form. If it the deliverable must be PDF, use a server side library to create a pre-filled PDF for delivery.

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
Participant ,
Jan 06, 2022 Jan 06, 2022

Copy link to clipboard

Copied

LATEST

Yeah a pre-filled pdf could work. I was hoping to make it more dynamic because it allows for more user control over what to input where  (without creating a web interface).

 

Thank you for your response either way, it atleast gives me insight as to why it's so hard to find information on getting this to work.

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