pdf2json icon indicating copy to clipboard operation
pdf2json copied to clipboard

pdf2json hangs in fonts.js in Font_buildToFontChar,

Open labsnoir opened this issue 7 years ago • 4 comments

The parsing of one PDF I try to read needs very long and the output result looks like eastern asian symbols although it should be german letters. The length of the array "toUnicode" in fonts.js is 4294967293 and most elements in it are undefined. The traversal of this array take some minutes in buildToFontChar(). Other PDFs can get parsed without problems immediately. Unfortunately I cannot provide the document as it contains private information. If you need further information or if I can check something, please tell me.

Some more information:

  • the version of pdf2json I use is 1.1.8
  • the font name parameter value of the calling function is TimesNewRomanPSMT.

Nevertheless: thank you for this great project!

Edit: It seems the problem is somewhere in readToUnicode() in evaluator.js. The big size of "toUnicode" is coming from the german umlauts "ä", "ö", "ü" und "ß".

labsnoir avatar Apr 21 '19 19:04 labsnoir

If the unicode conversion in evaluator.js in method readToUnicode() is commented out, (the lines beginning with // Convert "UTF-16BE"), the document is parsed correctly, although it is still very slow.

I don't know the internals of pdf, but could it be that there is something wrong with the meta data in that specific pdf file, for example information about encoding?

labsnoir avatar Apr 23 '19 21:04 labsnoir

All in all in my case it would help if readToUnicode() in evaluator.js could be disabled, for example by a parameter in PdfParser.

labsnoir avatar Apr 26 '19 14:04 labsnoir

Did you get around to fixing this issue?

sanath1188 avatar Apr 07 '21 07:04 sanath1188

if PR https://github.com/modesty/pdf2json/pull/401 doesn't fix it, upload the PDF please

modesty avatar Aug 24 '25 18:08 modesty