Using PDF-lib and Node.js to populate PDF form

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 37

  • @bjbk6373
    @bjbk6373 2 роки тому +4

    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
    😀

  • @xfilercuba
    @xfilercuba 2 роки тому +1

    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

  • @asyan.6526
    @asyan.6526 2 роки тому +1

    Thank you so much! This is exactly what I needed. You did an outstanding job - clear and to the point.

  • @mo3nnsoftware553
    @mo3nnsoftware553 2 роки тому

    Thank you for the video, have been searching for a while to get this done :)

  • @squidman8662
    @squidman8662 Рік тому

    That was beautifully done

  • @zeeu
    @zeeu 2 роки тому +5

    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)
    }
    })

  • @theinnoverse
    @theinnoverse 2 роки тому

    This was very helpful! Thanks!

  • @我展现速度222
    @我展现速度222 2 роки тому +2

    sir I did try to pass object value in the setText but it return undefined. how do I implement this. someone please help

  • @lodashnotebook5390
    @lodashnotebook5390 2 роки тому

    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!

  • @krishras23
    @krishras23 Рік тому

    is there a way to make the text boxes clickable in the first place, if they are not on the given pdf?

  • @willyhorizont8672
    @willyhorizont8672 2 роки тому

    Nice video. What package for convert pdf to image?

  • @skosso
    @skosso 2 роки тому

    is it possible to insert the data by taking them from a php form?

  • @JadeclonOfficial
    @JadeclonOfficial 2 роки тому +1

    How could I use this with react?

    • @fernandocibrianlira1779
      @fernandocibrianlira1779 Рік тому

      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);

  • @bencilao
    @bencilao 2 роки тому

    how would you know the type of the field from getFields method? is there a way?

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому

      getFields() returns an array of PDFFields - pdf-lib.js.org/docs/api/classes/pdffield

  • @amitkumdixit
    @amitkumdixit 2 роки тому

    Great,🙏 is pdf-lib is open source and free to use in production

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому

      Yes - it's MIT license - www.npmjs.com/package/pdf-lib?activeTab=readme#license

  • @gmanikamnaidu7338
    @gmanikamnaidu7338 2 роки тому

    can you plz make it with react js and node js dynamically

  • @drphil2424
    @drphil2424 2 роки тому

    Is it possible to connect this to a HTML front-end?

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому

      Yes - checkout the examples in the "web" app - github.com/Hopding/pdf-lib#complete-examples

    • @matthewnguyen3335
      @matthewnguyen3335 2 роки тому

      did you figure this out?

  • @Efootball2024.player.unknown
    @Efootball2024.player.unknown 2 роки тому

    How i can learn it from the beginning!

  • @janyajoshi
    @janyajoshi 2 роки тому

    how can I set form flattening ?...

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому +1

      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

  • @andersonsilva9998
    @andersonsilva9998 2 роки тому

    Exactly what I needed!
    Thank U so much! ô/

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому +1

      Glad this was useful!

    • @andersonsilva9998
      @andersonsilva9998 2 роки тому

      @@kalmanhazins9021 Hi, I'm here again... Do you know how I change the font? I need the Courier Font.

    • @kalmanhazins9021
      @kalmanhazins9021  2 роки тому

      @@andersonsilva9998 - stackoverflow.com/a/66091491/908842

  • @Ad-mv2ey
    @Ad-mv2ey Рік тому

    this wont work if ur pdf doesnt have a textfiled of checkboxes

  • @simonblurton8009
    @simonblurton8009 2 роки тому

    Your enter button must last a year how hard you hit it. Thank you for the tutorial.

  • @kalmanhazins9021
    @kalmanhazins9021  3 роки тому +1

    Github repo - github.com/kalmanh/form-filler.git to go along with the video

    • @RanjanaRawat-vt4tu
      @RanjanaRawat-vt4tu Рік тому

      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!

    • @maymoonaal-balushi4157
      @maymoonaal-balushi4157 Рік тому

      hey I think you should pin this comment, or add the repo in the description, it will be easier to find :)