go-fitz icon indicating copy to clipboard operation
go-fitz copied to clipboard

Error when convert PDF to Image

Open guoquanle opened this issue 1 year ago • 3 comments
trafficstars

cleancode.pdf when using doc.Image(pageNumber),this PDF will error, error page is 211.

error info: warning: jbig2dec error: DW value (-75) would make SYMWIDTH (0) negative at symbol 655 (segment 0) warning: jbig2dec warning: failed to decode; treating as end of file (segment 0) error: aborting process from uncaught error!

guoquanle avatar Jun 06 '24 07:06 guoquanle

Try with an external library, the bundled library is compiled without CJK.

gen2brain avatar Jun 07 '24 04:06 gen2brain

Any external library can be recommend? And I encountered a situation where there was no CJK before, and it gave such an error instead of a direct crash. error: cannot find builtin CJK font

guoquanle avatar Jun 07 '24 05:06 guoquanle

You need MuPDF library installed, then use extlib tag, and if needed add static or pkgconfig tags.

gen2brain avatar Jun 07 '24 05:06 gen2brain

Is it possible to catch this error? The fact that the process falls unexpectedly is very frustrating. Also, are there any recomendations how to make sure that my program get a proper (handleable) error without changes in the library? This crashes make me use pymupdf, wich is even more frustrating, than crash, because it is slow, but at least it throws handleable exceptions

blnvdanil avatar Sep 19 '24 12:09 blnvdanil

Now it will return error for broken files when load/run page is started.

gen2brain avatar Sep 27 '24 15:09 gen2brain