How to put data into a fillable PDF form and export it?
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
