-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using pdf-form-fill.js #223
Comments
try it with createWriterToModify like this
You can also try the PDFTK framework. Works better and you don't have problems with corrupted files. |
Thanks @DamickDoni, I appreciate the quick response. I have pretty much the same code as what you suggested, except I am outputting to the node response object rather than to a file. I tried using your suggestion and reading and writing to a file instead of using the response object and I get the same "inheritedProperties is not a function" error. I have also looked at PDFTK and it looks like it will fill the pdf form, but I haven't been able to figure out how to write an image to the pdf document in a specific location on one of the pages. Any suggestions? |
For your original question,
I have created a PR for it. For the second question, you can read this simple-image-drawing |
Thank you @chunyenHuang for your message. I changed the code in my pdf-form-fill.js file from inheritedProperties('DA') to inheritedProperties['DA']. The error is not occurring now, but unfortunately the form is not being filled - it is just displaying the blank pdf document. I added some console statements to the code to try to debug. When I look at the fieldsDictionary object (from line 136) it is: When I look at the inheritedProperties object (from the same line), it is just an empty object. Not sure what the da variable is used for, but it doesn't seem to be set correctly. Any help would be greatly appreciated. Joe |
Thanks @chunyenHuang I appreciate you looking into it. |
Since your {
"gender": 1, // 0-Female, 1-Male
"financeOption": 2 // 0-Direct Pay, 1-Not Interest, 2-Care Credit
} And you will have to modify the // from
updateOptionButtonValue(handles,fieldDictionary,(flags>>15) & 1 ? value : (value ? 0:null));
// to
var buttonValue = (!flags) ? value : (flags >> 15) & 1 ? value : value ? 0 : null
updateOptionButtonValue(handles, fieldDictionary, buttonValue); I am still investigating on the text fields. |
Thanks @chunyenHuang, I'll make that change and let you know how if works. In case it helps, attached is a pdf that was generated using the old java way of doing it. I wonder if that process replaced the form fields with text? I appreciate your help. |
@jhauckster @chunyenHuang where you ever able to get form-fill working with hummusjs? If so, could you post an simple example somewhere? |
Form filling "works" partially, in my case, I have values written when I click on a form field, but nothing displayed when print.. >< I tried many PDF versions, different cases, maybe someone has an idea ? After many tries, i think that this issue is related to the size of form fields.. I can't make it work for almost 80% of a simple document :/ |
@chunyenHuang I have the same issue the text controls values are displayed only if you focus on them. |
Hello and thank you for developing HummusJS! For years we have been working in a Java environment where we take an existing pdf containing a form, fill the form values programmatically, and insert a signature image. We are looking to recreate this functionality in nodejs - which is how we came upon HummusJS.
I tested one of our existing PDFs using the pdf-form-fill.js code that you provided, but I get the following error:
TypeError: inheritedProperties is not a function
at writeAppearanceXObjectForText (/usr/src/app/src/pdf-form-fill.js:136:90)
at writeFieldWithAppearanceForText (/usr/src/app/src/pdf-form-fill.js:224:3)
at updateTextValue (/usr/src/app/src/pdf-form-fill.js:256:3)
at updateFieldWithValue (/usr/src/app/src/pdf-form-fill.js:323:7)
at writeFilledField (/usr/src/app/src/pdf-form-fill.js:388:5)
at /usr/src/app/src/pdf-form-fill.js:436:7
Attached is the pdf called reg2.pdf and here is my node server code:
app.get('/fill', function (req, res) {
try {
res.writeHead(200, {'Content-Type': 'application/pdf'})
var pdfWriter = hummus.createWriterToModify(
new hummus.PDFRStreamForFile(__dirname + "/reg2.pdf"),
new hummus.PDFStreamForResponse(res)
)
var data = {
"firstName": "Eric",
"lastName": "Jones",
"gender": "M",
"financeOption": "Direct Pay"
}
} catch (err) {
res.end()
console.log('fill error', err)
}
})
Any idea why I am getting this error?
Thanks for your help,
Joe
reg2.pdf
The text was updated successfully, but these errors were encountered: