galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Not filling the form #332

Closed MrShakes closed 5 years ago

MrShakes commented 5 years ago

I'm trying to fill the fillable parts of this pdf and it's not working, I'm not getting an error either although using another pdf library(pdf-fill-form) I got "Error: Invalid XRef entry", don't know for sure if related. I've been able to read the fields of the form, trying to fill just creates the same exact pdf with no filled inputs, this is the pdf I'm trying to fill: fw4.pdf and my code:

var hummus = require('hummus');
var fillForm = require('./pdf-form-fill');

var writer = hummus.createWriterToModify(__dirname + '/sample-forms/fw4.pdf', {
     modifiedFilePath: __dirname + '/Test.pdf'
 });

        var data = {
          "topmostSubform[0].Page1[0].Line1[0].f1_1[0]": null,
          "topmostSubform[0].Page1[0].Line1[0].f1_2[0]": null,
          "topmostSubform[0].Page1[0].Line1[0].f1_3[0]": "Ola",
          "topmostSubform[0].Page1[0].Line1[0].f1_4[0]": "Ola",
          "topmostSubform[0].Page1[0].f1_13[0]": "Ola",
          "topmostSubform[0].Page1[0].c1_1[0]": true,
          "topmostSubform[0].Page1[0].c1_1[1]": true,
          "topmostSubform[0].Page1[0].c1_1[2]": true,
          "topmostSubform[0].Page1[0].c1_2[0]": true,
          "topmostSubform[0].Page1[0].f1_5[0]": null,
          "topmostSubform[0].Page1[0].f1_6[0]": null,
          "topmostSubform[0].Page1[0].f1_7[0]": null,
          "topmostSubform[0].Page1[0].f1_8[0]": null,
          "topmostSubform[0].Page1[0].f1_9[0]": null,
          "topmostSubform[0].Page1[0].f1_10[0]": null,
          "topmostSubform[0].Page3[0].f3_1[0]": null,
          "topmostSubform[0].Page3[0].f3_2[0]": null,
          "topmostSubform[0].Page3[0].f3_3[0]": null,
          "topmostSubform[0].Page3[0].f3_4[0]": null,
          "topmostSubform[0].Page3[0].f3_5[0]": null,
          "topmostSubform[0].Page3[0].f3_6[0]": null,
          "topmostSubform[0].Page3[0].f3_7[0]": null,
          "topmostSubform[0].Page3[0].f3_8[0]": null,
          "topmostSubform[0].Page3[0].f3_9[0]": null,
          "topmostSubform[0].Page3[0].f3_10[0]": null,
          "topmostSubform[0].Page3[0].f3_11[0]": null,
          "topmostSubform[0].Page3[0].f3_12[0]": null,
          "topmostSubform[0].Page3[0].f3_13[0]": null,
          "topmostSubform[0].Page3[0].f3_14[0]": null,
          "topmostSubform[0].Page3[0].f3_15[0]": null,
          "topmostSubform[0].Page3[0].f3_16[0]": null,
          "topmostSubform[0].Page3[0].f3_17[0]": null,
          "topmostSubform[0].Page3[0].f3_18[0]": null,
          "topmostSubform[0].Page4[0].f4_1[0]": null,
          "topmostSubform[0].Page4[0].f4_2[0]": null,
          "topmostSubform[0].Page4[0].f4_3[0]": null,
          "topmostSubform[0].Page4[0].f4_4[0]": null,
          "topmostSubform[0].Page4[0].f4_5[0]": null,
          "topmostSubform[0].Page4[0].f4_6[0]": null,
          "topmostSubform[0].Page4[0].f4_7[0]": null,
          "topmostSubform[0].Page4[0].f4_8[0]": null,
          "topmostSubform[0].Page4[0].f4_9[0]": null
        };

      fillForm.fillForm(writer, data);
      writer.end();

Hummus 1.0.90 Node 8.11.2

MrShakes commented 5 years ago

Update: It's filling, not just showing up in my Adobe Acrobat Pro 10.0.0, showed up when I uploaded to Google Drive and used the default Pdf viewer there