Using HummusJS to fill government pdf forms I cannot figure out why the filled values do appear when I open the filled pdf forms in Chrome/Firefox but do not appear when I open them in Acrobat Reader.
Using filling-form-values and modifying the main.js
code for the fields to be filled and an example I-130 pdf form:
var hummus = require('hummus'),
fillForm = require('./pdf-form-fill').fillForm;
var filename = 'i-130.pdf';
var writer = hummus
.createWriterToModify(__dirname + '/sample-forms/' + filename, {
modifiedFilePath: __dirname + '/output/' + filename + '_out.pdf'
});
var data = {
"form1[0].#subform[0].Pt2Line4a_FamilyName[0]" : "LAST filled",
"form1[0].#subform[0].Pt2Line4b_GivenName[0]" : 'FIRST filled ',
"form1[0].#subform[0].Pt2Line4c_MiddleName[0]" : 'MIDDLE filled',
}
fillForm(writer,data);
writer.end();
Here's how it looks in Chrome with the correct filled values (no concerns on alignment - I know how to fix that) :
And here's how it appears in Acrobat Reader - sad empty fields :
If I parse the filled PDF using HummusJS Samples parsing-form-values, the values are there in those filled fields. eg:
{
"name": "Pt2Line4a_FamilyName[0]",
"fullName": "form1[0].#subform[0].Pt2Line4a_FamilyName[0]",
"alternateName": "Part 2. Information About You (Petitioner). Your Full Name. 4. A. Enter Family Name (Last Name).",
"isNoExport": false,
"isFileSelect": false,
"type": "plaintext",
"value": "LAST filled"
},
{
"name": "Pt2Line4b_GivenName[0]",
"fullName": "form1[0].#subform[0].Pt2Line4b_GivenName[0]",
"alternateName": "Part 2. Information About You (Petitioner). Your Full Name. 4. B. Enter Given Name (First Name).",
"isNoExport": false,
"isFileSelect": false,
"type": "plaintext",
"value": "FIRST filled "
},
{
"name": "Pt2Line4c_MiddleName[0]",
"fullName": "form1[0].#subform[0].Pt2Line4c_MiddleName[0]",
"alternateName": "Part 2. Information About You (Petitioner). Your Full Name. 4. C. Enter Middle Name.",
"isNoExport": false,
"isFileSelect": false,
"type": "plaintext",
"value": "MIDDLE filled"
},
I've tried running this on both Windows and Linux with the same result.
The values don't appear in Acrobat Reader even if you click into those fields.
I've also tried the loading fonts to rule that out with same result.
var font = handles.writer.getFontForFile(__dirname + '/arial.ttf');
xobjectForm.getContentContext()
.BT() // Begin Text writing
.k(0,0,0,1) // set color to Black (cmyk = 0,0,0,1)
.Tf(font,10) // set font; size 20
.Tm(1,0,0,1,10,10) // set position to 0,40 in this object
.Tj('YO YO YO!!') // set text
.ET() // end text writing
Anyone have any ideas or pointers?