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
Copy link to clipboard
Copied
Hi Test Screen Name,
Thank you for your reply. You really gave me lots of hints and methods of what I need to do. After confirming with my supervisor, my task is to write a piece of code to populate an existed PDF form with data. No matter on a server or not. It can be done on a local desktop or on a web page. So I decided to implement this via acrobat API(local process). Thank you for helping me.
Changjian
Copy link to clipboard
Copied
Ok - Let's start over. First, forget about using the code you already have. While it is JavaScript, it isn't JavaScript that is written for Acrobat or Reader. Please describe exactly what you want to do. Be specific. Where is the PDF? Where is the data? How do you expect the PDF to communicate to where the data exists? Is this something you run yourself or will your users (known or unknown) filling the PDF or causing it to be filled?
Copy link to clipboard
Copied
Hi Joel_Geraci,
Thank you for your reply.
What I need to do is to write a piece of code to populate an existed PDF form with data. No matter on a server or not. It can be done on a local desktop if I use Acrobat API. The PDF form and the data are both already hone in my desktop. I need to put the data into PDF form programmatically. So I am trying to implement it by using Acrobat API. Sometimes I got confused because I am still a beginner level of coding. I will continue learning it.
Changjian
Copy link to clipboard
Copied
Ok - What format is the data in? Can it be put into Excel? If so, your task is fairly simple.