Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4618168
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:13:40+00:00 2026-05-22T02:13:40+00:00

When parsing a PDF, given a string (popped from the Tj or TJ operator

  • 0

When parsing a PDF, given a string (popped from the Tj or TJ operator callbacks) with the Identity-H encoding how do you map that string to a unicode (say UTF8) representation?

If I need a CMap for this, how do I create (or retrieve) and apply the CMap?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:13:41+00:00Added an answer on May 22, 2026 at 2:13 am

    You’ll probably have to parse the font data itself. Identity-H just means “use the bytes as raw glyph indexes into the given font”. That’s why you MUST embed fonts when using Identity-H… different versions of the same font need not have the same glyph order.

    There’s example code on how to do this sort of thing in several different open source projects. iText, for example (yes, I’m biased).


    You’d mentioned a CMap. Identity-H fonts can have a CMap but aren’t required to do so. The /ToUnicode entry will be a stream that is a CMap, as defined in some adobe spec somewhere. They aren’t all that complex:

    /CIDInit /ProcSet findresource begin  
    12 dict begin  
    begincmap  
    /CIDSystemInfo  
    << /Registry (TTX+0)  
    /Ordering (T42UV)  
    /Supplement 0  
    >> def  
    /CMapName /TTX+0 def  
    /CMapType 2 def
    1 begincodespacerange  
    <0000><FFFF>  
    endcodespacerange  
    80 beginbfrange  
    <0003><0003><0020>  
    <0024><0024><0041>  
    <0025><0025><0042>  
    <0026><0026><0043>  
    <0027><0027><0044>  
    <0028><0028><0045>  
    <0029><0029><0046>  
    <002a><002a><0047>  
    <002b><002b><0048>
    <002c><002c><0049>
    <002d><002d><004a>
    <002e><002e><004b>
    <002f><002f><004c>
    <0030><0030><004d>
    <0031><0031><004e>
    <0032><0032><004f>
    <0033><0033><0050>
    <0034><0034><0051>
    <0035><0035><0052>
    <0036><0036><0053>
    <0037><0037><0054>
    <0038><0038><0055>
    <0039><0039><0056>
    <003a><003a><0057>
    <003b><003b><0058>
    <003c><003c><0059>
    <003d><003d><005a>
    <0065><0065><00c9>
    <00c8><00c8><00c1>
    <00cb><00cb><00cd>
    <00cf><00cf><00d3>
    <00d2><00d2><00da>
    <00e2><00e2><0160>
    <00e4><00e4><017d>
    <00e9><00e9><00dd>
    <00fd><00fd><010c>
    <0104><0104><0104>
    <0106><0106><010e>
    <0109><0109><0118>
    <010b><010b><011a>
    <0115><0115><0147>
    <011b><011b><0158>
    <0121><0121><0164>
    <0123><0123><016e>
    <01a0><01a0><0116>
    <01b2><01b2><012e>
    <01cb><01cb><016a>
    <01cf><01cf><0172>
    <022c><022c><0401>
    <023b><023b><0411>
    <023c><023c><0412>
    <023d><023d><0413>
    <023e><023e><0414>
    <023f><023f><0415>
    <0240><0240><0416>
    <0241><0241><0417>
    <0242><0242><0418>
    <0243><0243><0419>
    <0244><0244><041a>
    <0245><0245><041b>
    <0246><0246><041c>
    <0247><0247><041d>
    <0248><0248><041e>
    <0249><0249><041f>
    <024a><024a><0420>
    <024b><024b><0421>
    <024c><024c><0422>
    <024d><024d><0423>
    <024e><024e><0424>
    <024f><024f><0425>
    <0250><0250><0426>
    <0251><0251><0427>
    <0252><0252><0428>
    <0253><0253><0429>
    <0254><0254><042a>
    <0255><0255><042b>
    <0256><0256><042c>
    <0257><0257><042d>
    <0258><0258><042e>
    <0259><0259><042f>
    endbfrange
    endcmap
    CMapName currentdict /CMap defineresource pop
    end end
    

    Wow. That particular CMap is horribly inefficient. A “bfrange” starts from parameter 1, and goes to and includes parameter 2, maping values starting at parameter 3 (and continuing on until there are no more things to map.

    For example:

    <0003><0003><0020>
    <0024><0024><0041>
    <0025><0025><0042>
    <0026><0026><0043>
    <0027><0027><0044>
    <0028><0028><0045>
    <0029><0029><0046>
    <002a><002a><0047>
    <002b><002b><0048>
    <002c><002c><0049>
    <002d><002d><004a>
    <002e><002e><004b>
    <002f><002f><004c>
    <0030><0030><004d>
    <0031><0031><004e>
    <0032><0032><004f>
    

    could be represented as

    <0003><0003><0020>
    <0024><0032><0041>
    

    A quick google search turned up the CMap/CID font spec.

    There are also beginbfchar/endbfchar which just take two parameters (src and dest values, no ranges), CID based versions (at which point you need to have access to Adobe’s character ID tables. They’re part of Acrobat/Reader installations, though Reader will need to be prodded into downloading the various Language Packs (or kits or whatever they’re called)), and various other stuff you really out to read that spec to find out about.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing text from a file and storing it in a string. The problem
I'm looking at parsing a delimited string, something on the order of a,b,c But
I've been parsing through some log files and I've found that some of the
I am parsing text that has a heading and then data that applies to
I am parsing an RSS feed from the following URL: http://rss.sciam.com/ScientificAmerican-Global?format=xml // $xml_text is
I am stuck with parsing a PDF file. Please guide me how to do
Hey everyone, I am working on parsing the PDF content stream to be able
Parsing a text file in vb.net and need to locate the latitude and longitude
For parsing player commands, I've most often used the split method to split a
I`m parsing SQL query with C# Regex. I need also to make my pattern

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.