Nice job! FYI to anyone who is working with PDF-Lib and encounters an encrypted PDF like this, the `PDFDocument.load()` function takes an object parameter that can be passed to it called ignoreEncryption and set the property to true. The error that was thrown in the video at around time index 4:05 shows that you can use PDFDocument.load(…, { ignoreEncryption: true } ) So like so: `const pdfDoc = await PDFDocument.load(await readFile(input), { ignoreEncryption: true })` no need for the third party website like ilovepdf to unlock. Great overview of filling forms with PDF-Lib! Thanks @kalman 😀
Great thank you. I was reading the documentation on pdf-lib but couldn't figure out how to use the file system instead of URL as in the examples. Gonna follow your instructions. Thanks again
Thank you very much sir ❤ I find a better why to figure out the name of each input field, with the code below you will be able to open your output pdf file and see each text input filled with its name and each checkbox checked : const form = pdfDoc.getForm() const fields = form.getFields() fields.forEach(field => { const type = field.constructor.name const name = field.getName() if(type == 'PDFCheckBox') { console.log(`${type}: ${name}`) field.check() } else { field.setText(name) } })
You have a unique ability to teach. I've seen many people and work from home tutors on Udemy and other places, but you have a level of patience that is critical for knowledge transfer. Keep it up!
import _raw from "./pruebaPDForm.pdf"; then const existingPdfBytes = await fetch(_raw).then((res) => res.arrayBuffer()); // Load a PDFDocument from the existing PDF bytes const pdfDoc = await PDFDocument.load(existingPdfBytes);
Hi, I am getting field name like this IMM_0194[0].Page1[0].Forms[0].question1[0].questionText[0].List[0].checkBox[0].CheckBox[0] (type is object). Could you please give a solution how I can get simpler names? Thanks!
Nice job! FYI to anyone who is working with PDF-Lib and encounters an encrypted PDF like this, the `PDFDocument.load()` function takes an object parameter that can be passed to it called ignoreEncryption and set the property to true. The error that was thrown in the video at around time index 4:05 shows that you can use PDFDocument.load(…, { ignoreEncryption: true } )
So like so: `const pdfDoc = await PDFDocument.load(await readFile(input), { ignoreEncryption: true })`
no need for the third party website like ilovepdf to unlock. Great overview of filling forms with PDF-Lib! Thanks @kalman
😀
Great thank you. I was reading the documentation on pdf-lib but couldn't figure out how to use the file system instead of URL as in the examples. Gonna follow your instructions. Thanks again
Thank you so much! This is exactly what I needed. You did an outstanding job - clear and to the point.
Thanks!
Thank you for the video, have been searching for a while to get this done :)
That was beautifully done
Thank you very much sir ❤
I find a better why to figure out the name of each input field, with the code below you will be able to open your output pdf file and see each text input filled with its name and each checkbox checked :
const form = pdfDoc.getForm()
const fields = form.getFields()
fields.forEach(field => {
const type = field.constructor.name
const name = field.getName()
if(type == 'PDFCheckBox') {
console.log(`${type}: ${name}`)
field.check()
} else {
field.setText(name)
}
})
Yep - good work!
This was very helpful! Thanks!
sir I did try to pass object value in the setText but it return undefined. how do I implement this. someone please help
You have a unique ability to teach. I've seen many people and work from home tutors on Udemy and other places, but you have a level of patience that is critical for knowledge transfer. Keep it up!
Appreciate the compliment! :)
is there a way to make the text boxes clickable in the first place, if they are not on the given pdf?
Nice video. What package for convert pdf to image?
is it possible to insert the data by taking them from a php form?
How could I use this with react?
import _raw from "./pruebaPDForm.pdf"; then
const existingPdfBytes = await fetch(_raw).then((res) => res.arrayBuffer());
// Load a PDFDocument from the existing PDF bytes
const pdfDoc = await PDFDocument.load(existingPdfBytes);
how would you know the type of the field from getFields method? is there a way?
getFields() returns an array of PDFFields - pdf-lib.js.org/docs/api/classes/pdffield
Great,🙏 is pdf-lib is open source and free to use in production
Yes - it's MIT license - www.npmjs.com/package/pdf-lib?activeTab=readme#license
can you plz make it with react js and node js dynamically
Is it possible to connect this to a HTML front-end?
Yes - checkout the examples in the "web" app - github.com/Hopding/pdf-lib#complete-examples
did you figure this out?
How i can learn it from the beginning!
how can I set form flattening ?...
Check out the following example - jsfiddle.net/Hopding/skevywdz/2/ Here is a link to the API - pdf-lib.js.org/docs/api/classes/pdfform#flatten
Exactly what I needed!
Thank U so much! ô/
Glad this was useful!
@@kalmanhazins9021 Hi, I'm here again... Do you know how I change the font? I need the Courier Font.
@@andersonsilva9998 - stackoverflow.com/a/66091491/908842
this wont work if ur pdf doesnt have a textfiled of checkboxes
Your enter button must last a year how hard you hit it. Thank you for the tutorial.
Github repo - github.com/kalmanh/form-filler.git to go along with the video
Hi, I am getting field name like this IMM_0194[0].Page1[0].Forms[0].question1[0].questionText[0].List[0].checkBox[0].CheckBox[0] (type is object). Could you please give a solution how I can get simpler names? Thanks!
hey I think you should pin this comment, or add the repo in the description, it will be easier to find :)