-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
Trying to parse invalid object #369
Comments
Hello @antoinerousseau! The warnings will not cause you any issues. pdf-lib's parser failed to parse those objects, but that's because they are a very specific type of empty object that don't do anything in your document anyways. Regardless, I fixed the parser bug in #370. So when the next release of pdf-lib goes out, you will no longer see these warnings. |
Wow, so fast, thanks! |
Haha, indeed. They are useless as far as I can tell. Though, even if they aren't, smallpdf.com could eliminate the extra whitespace in them. But they only contribute a few bytes to the total size of the document, so I guess it's probably more effort than its worth for them. |
Hi,
How can I solve this issue? |
@yakupteke did you read this thread?...
|
@antoinerousseau Version You can install this new version with npm:
It's also available on unpkg: As well as jsDelivr: |
Thanks a lot. |
Hi @Hopding, I seem to be running into the same issue when I delete a page from some PDF files, like this one. I'm using 1.4.1 and seeing the console warnings below:
Do you have any idea why that would be happening? Sample relevant code, nothing too wild:const deleteFirstPage = async (pdfUrl: string) => {
const pdfBytes: ArrayBuffer = await axios
.get(pdfUrl, {
responseType: 'arraybuffer'
})
.then(res => res.data as ArrayBuffer)
const document = await PDFDocument.load(pdfBytes)
document.removePage(1)
const updatedPdfBytes = await document.save()
return new Blob([updatedPdfBytes], { type: 'application/pdf' })
} |
I just installed this package.. Im using 1.4.1 and i still get the parse invalid object error. Any idea? Thanks |
@deammer It looks like the problem you're encountering is due to the fact that your PDF is encrypted. Just to be clear, when I run the following script: import { PDFDocument } from 'pdf-lib';
(async () => {
const url = 'https://www.uscis.gov/sites/default/files/files/form/i-130.pdf';
const i130Bytes = await fetch(url).then((res) => res.arrayBuffer());
const pdfDoc = await PDFDocument.load(i130Bytes);
})(); It produces the following output:
Notice the encryption error. The |
@kimsean Can you share the document that is causing the error? |
Still getting this error. Link for the PDF file: https://www.icloud.com/iclouddrive/0de0B7Vuvr6gTeYYAn4c9GC_Q#large |
same to me |
Hi @Hopding, do you mind reopening this issue? I am on Thank you. |
The same here!
|
If anybody is having trouble with this (for non-encrypted PDFs), please create a new bug report |
Does anyone know a way around this error ? the same erro pdf: https://drive.google.com/file/d/14K67CUc5fZ3XPbXYlHQPUW3PXufxPRVZ/view?usp=sharing |
@Hopding const buffer = await page.pdf([options];
// Give the buffer to pdf-lib;
const pdfDoc = await PDFDocument.load(buffer); error log: err message: Failed to parse PDF document (line:47350 col:464825 offset=8891): Failed to parse invalid PDF object
err stack: Error: Failed to parse PDF document (line:47350 col:464825 offset=8891): Failed to parse invalid PDF object
at PDFInvalidObjectParsingError.PDFParsingError [as constructor] (/node_modules/pdf-lib/cjs/core/errors.js:229:24)
at new PDFInvalidObjectParsingError (/node_modules/pdf-lib/cjs/core/errors.js:262:24)
at PDFParser.tryToParseInvalidIndirectObject (/node_modules/pdf-lib/cjs/core/parser/PDFParser.js:181:19)
at PDFParser.<anonymous> (/node_modules/pdf-lib/cjs/core/parser/PDFParser.js:209:30) I'm not sure if this is a bug or a concurrency problem, it's not necessary, I found it in the error log, I look forward to your help, thank you very much |
i believe the new bug report is at #1274 |
When I open my beautiful PDF with this lib, all is great.
But because the file is big, I compressed it using smallpdf.com, and now when I open the compressed version, I get these warnings:
Any idea why? Is this an issue if I just use
drawText
?The text was updated successfully, but these errors were encountered: