Where can I a mapping of Identity-H encoded characters to ASCII or Unicode characters?

18,742

It is not always possible to extract text from a PDF especially when the /ToUnicode map is missing as pointed out by mkl.

If it is not possible to cut and paste the correct text from Acrobat then you will have very little chance of extracting the text yourself. If Acrobat cannot extract it then it is very unlikely that any other tool can extract the text correctly.

If you manually create an encoding table then you could use this to remap the extracted characters to their correct values but this most likely will only work for this one document.

Often this is done on purpose. I have seen documents that randomly remap characters differently for each font in the dot. It is used as a form of obfuscation and the only real way to extract text from these PDF's is to resort to OCR. There are many financial reports that use this type of trick to stop people from extracting their data.

Also, Identity-H is just a 1:1 character mapping for all characters from 0x0000 to 0xFFFF. ie. Identity is an identity mapping.

Your real problem is the missing /ToUnicode entry in this PDF. I suspect there is also an embedded CMap in your PDF that explains why there could be 3 bytes per character.

Share:
18,742
Chas. Owens
Author by

Chas. Owens

UNIX, Perl, what more is there to say?

Updated on June 05, 2022

Comments

  • Chas. Owens
    Chas. Owens almost 2 years

    I have a PDF generated by a third party. I am trying to get the text out of it, but neither pdf2text nor copying and pasting results in readable text. After a little digging in the output (of either of two) I found that each character on the screen is made up of three bytes. For example, "A" is the bytes ef, 81, and 81. Looking at the metadata on the PDF it claims to be encoded in Identity-H, so I assume what I am seeing is a set of characters encoded in Identity-H. I have a partial mapping based on the documents I already have, but I want to make a more complete mapping. To do that I need something like an ASCII table for Identity-H.