During flatten, expected instance of PDFDict or PDFStream, but got instance of undefined
See original GitHub issueHello!
I’m encountering the following crash when trying to flatten a W4 from the IRS’ website.
/home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/errors.js:38
this = _super.call(this, msg) || this;
^
Error: Expected instance of PDFDict or PDFStream, but got instance of undefined
at new UnexpectedObjectTypeError (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/errors.js:38:24)
at PDFContext.lookup (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/PDFContext.js:93:15)
at PDFDict.lookup (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/objects/PDFDict.js:64:48)
at PDFWidgetAnnotation.PDFAnnotation.getAppearances (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/annotation/PDFAnnotation.js:89:20)
at PDFTextField.needsAppearancesUpdate (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/api/form/PDFTextField.js:670:48)
at PDFForm.updateFieldAppearances (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/api/form/PDFForm.js:534:23)
at PDFForm.flatten (/home/ubuntu/src/x/node_modules/pdf-lib/cjs/api/form/PDFForm.js:450:18)
at file:///home/ubuntu/src/x/fillOut.js:293:6
Using v1.16.0, any suggestions to workaround this issue?
My code adds a bunch of text (it doesn’t use the Form API, just writes at given coordinates), and then flatten the PDF using PDFForm.flatten().
Issue Analytics
- State:
 - Created 3 years ago
 - Comments:5 (1 by maintainers)
 
Top Results From Across the Web
During flatten, expected instance of PDFDict or PDFStream ...
I'm encountering the following crash when trying to flatten a W4 from the IRS' website. /home/ubuntu/src/x/node_modules/pdf-lib/cjs/core/ ...
Read more >Trying to use pdf-lib to fill pdf form fields. Trouble Flattening ...
The issue I am having is that I want to be able to Flatten and Save the form after any online editing after...
Read more >iTextSharp.xml - eSport
Begins handling of current pdf stream decompression. this instance. ... null iText expects Arabic Diactrics (tashkeel) to have zero advance but some fonts, ......
Read more >iText Knowledge Base
I use ((PdfStream)obj).getBytes(), iText will look at the filter. For instance: page content streams consists of PDF syntax ...
Read more >iTextSharp.xml
itextsharp An Anchor can be a reference or a destination of a reference. ... A Phrase has a main Font, but some chunks...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It also worked for me to “touch” all field via setting an empty text as value inside:
Please fill out the new bug report form if you’re still having trouble with this.