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

How to put data into a fillable PDF form and export it?

Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Copy link to clipboard

Copied

Hi all,

I've asked a similar question before: How to use external data to fill in an existing PDF form in JavaScript?

Also, I learned these two links as references:

Batch-Import Excel Data into PDF Forms - KHKonsulting LLC

Batch-Import List Data into PDF Form - KHKonsulting LLC

But I still have some questions because I don't have JavaScript experience before, still a beginner now. Any help and suggestions are appreciated.

What I would like to do is put the "username" and "age" to a fillable pdf form. I've already written some JS script.

==========================================================

var userInfo = {                                               // data source
   userOne: {

   name : "Max M",
   age : "100"},
   userTwo: {

   name: 'Louise H',
   age: '200'
   }

}

function getUserInfo(id, key) {                    // get data
   return userInfo[id][key];
}

class User {                                               // create a class to store data
   constructor (id) {

   this.userData = {};
   var requiredList = ['name', 'age'];           // can be added
   requiredList.forEach((key)=>{

   this.userData[key] = getUserInfo(id, key);
   });
   }

}

function getAllInfo(id) {                                // return the data
   var user = new User(id);
   return user.userData;
}

=======================================================

The PDF form is like:

What I don't know are :

1. how to import a pdf in this code

2. export this pdf after filling that data above

Thank you so much for any help!

Changjian

TOPICS
Acrobat SDK and JavaScript , Windows

Views

2.0K

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 ,
Apr 25, 2018 Apr 25, 2018

Copy link to clipboard

Copied

You must use JavaScript, 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
Community Beginner ,
Apr 25, 2018 Apr 25, 2018

Copy link to clipboard

Copied

Yes, I know. The language I used is JavaScript. But I don't know how to fill pdf form and export it.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

What do you mean by "import a PDF". You already have a PDF, just have it open.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Sorry, it seems that I use the wrong word. I mean, open that PDF that I've already had, and edit (put the data into it), then generate to download. So I don't know how to "open" and "generate" it using JavaScript. And where to put this code...Could you please help me with it? Thank you so much.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

What want you download?

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

https://forums.adobe.com/people/Maximilion+Ma  wrote

Yes, I know. The language I used is JavaScript. But I don't know how to fill pdf form and export it.

You use this code in Adobe Acrobat?

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

I use this code in JetBrains WebStorm, a JS IDE, to implement this. Can you please give me some advice? Thank you .

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

You want fill a form on a server?

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

No, not on a server. I just assume that I already get the data, it doesn't matter where the data is. It is like a prototype, just a function or a script. I just learn JS from the beginning, so it is a little bit challenging for me to implement this function. 

Actually, it is similar to this: Batch-Import List Data into PDF Form - KHKonsulting LLC

But in this link, I can not find how to open that that existed pdf and how to generate that pdf form to be ready to download. So feel confused.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

You must open the PDF file in Adobe Acrobat and execute the JavaScript code in Acrobat.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

OK, I got it. I will do some further research on that.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

You can't use the "class" keyword in Acrobat JS. It's from a version (ECMAScript 4) that's not supported by it.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Thank you for your advice. May I ask which keyword can replace it? Thank you!

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

It's not just a question of replacing one keyword with another. You need to write your code in a different way.

I would say you can use a function, but it must return an object. Also, I'm not too sure about the "constructor" command...

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

So, you do want something for a server (if you want it to be ready to download)?

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Yes, I want that pdf can be downloaded after filling in the data.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Please answer because it is very important,  both technically and legally. You want this filling to happen on a server (so it can be downloaded)? Or not?

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Actually I don't know what's the difference between on a server or not on server. My requirement is only fill in the pdf form and can be downloaded. I just assume that I already get the data, it doesn't matter where the data is. It is like a prototype, just a function or a script.

My university supervisor told me to implement this prototype function. That's it. I really don't know more about it. 

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

It really matters where your data is, because Acrobat is not licensed for server use. You need to understand whether your project can be done legally! To understand the difference between "on server" and "not on server", let's try and understand what exactly you mean by "download". Is there a web site? What actions do you see that make the "download".

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Yes, there is a web page(HTML)  actually, the function I need to implement is: when a user clicks the button on that web page, some data(fake) can be auto-filled in a fillable pdf form and display on the screen, I mean, if the form can be displayed , it can also be downloaded, right?  It is just a small function.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

That's not the issue. The issue is that you can't use Acrobat as a server application, neither technically (it wasn't built for it) nor legally (the EULA forbids it).

What you're describing can be achieved using either a server-side script or a stand-alone application. I've created solutions that take input from an HTML page to a PHP script, which in turn calls a Java application to populate a PDF form with data, and return it to the user.

It's probably possible to do it without the Java part, too. Another option is to generate an FDF file and load it into the PDF, but that won't always work (it depends on the viewer used in the browser).

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

Hi try67,

Thank you for your reply. I have a clear mind regarding to my function after reading your comment. A server-side implementation is the ideal one. A stand-alone application is also acceptable for my case.

Could you please send me a sample of the solution you've created in a server-side using java and PHP ? A link or via email, both are ok.  I would like to learn something new, something I don't know. Thank you so much.

Changjian

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 ,
Apr 27, 2018 Apr 27, 2018

Copy link to clipboard

Copied

You can contact me privately (try6767 at gmail.com) to discuss it further.

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 ,
Apr 26, 2018 Apr 26, 2018

Copy link to clipboard

Copied

"Just a small function" means "just use Acrobat a little bit". Since you can't legally use it AT ALL that's a non starter. And JavaScript is a way (for this purpose) of controlling Acrobat. So you need to look at the bigger picture. Server solutions and desktop solutions almost always involve entirely different software, so it's always the first question to ask.

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