galkahana / HummusJS

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

getSourceDocumentParser exits process #309

Closed chunyenHuang closed 6 years ago

chunyenHuang commented 6 years ago

hello Gal, I have an issue for the getSourceDocumentParser

const copyCtx = pdfWriter.createPDFCopyingContext(src);
oldInfo = copyCtx.getSourceDocumentParser().queryDictionaryObject(
copyCtx.getSourceDocumentParser().getTrailer(), "Info"
).toJSObject();

This code exit with segment fault 11 for some pdfs and it's not catchable.

292

galkahana commented 6 years ago

probably that "info" is not in the trailer? then you're getting something not entirely wonderful and toJSObject just freaks out.

yeah...maybe if i find some free time i'll have all methods throw and return properly. not too much work, i just need to adapt code that i havent since node 0.10. the conditions are there....just changes in node implementation kind of screwed things up and i never got to fix stuff.

you can check what you're getting back in the meantime, or whether "Info" actually exists.

galkahana commented 6 years ago

k. done this and published as 1.0.88. try getting the new build and see what happens. I expect that you'll get an error trying to toJSObject() on undefined (instead of segfault)

chunyenHuang commented 6 years ago

Thanks @galkahana, this has been a pain for me. I will test it soon.

chunyenHuang commented 6 years ago

It works perfectly thanks.