{"record":{"id":"698f920ea99e9aa3","repo":"mozilla/pdf.js","slug":"unknown-cmap-name-name","errorCode":null,"errorMessage":"Unknown CMap name: ${name}","messagePattern":"Unknown CMap name: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/cmap.js","lineNumber":679,"sourceCode":"  // Merge the map into the current one, making sure not to override\n  // any previously defined entries.\n  cMap.useCMap.forEach(function (key, value) {\n    if (!cMap.contains(key)) {\n      cMap.mapOne(key, value);\n    }\n  });\n\n  return cMap;\n}\n\nasync function createBuiltInCMap(name, fetchBuiltInCMap) {\n  if (name === \"Identity-H\") {\n    return new IdentityCMap(false, 2);\n  } else if (name === \"Identity-V\") {\n    return new IdentityCMap(true, 2);\n  }\n  if (!BUILT_IN_CMAPS.includes(name)) {\n    throw new Error(\"Unknown CMap name: \" + name);\n  }\n  if (!fetchBuiltInCMap) {\n    throw new Error(\"Built-in CMap parameters are not provided.\");\n  }\n\n  const { cMapData, isCompressed } = await fetchBuiltInCMap(name);\n  const cMap = new CMap(true);\n\n  if (isCompressed) {\n    return new BinaryCMapReader().process(cMapData, cMap, useCMap =>\n      extendCMap(cMap, fetchBuiltInCMap, useCMap)\n    );\n  }\n  const lexer = new Lexer(new Stream(cMapData));\n  return parseCMap(cMap, lexer, fetchBuiltInCMap, null);\n}\n\nclass CMapFactory {","sourceCodeStart":661,"sourceCodeEnd":697,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cmap.js#L661-L697","documentation":"Thrown by createBuiltInCMap when the requested CMap name is neither Identity-H/Identity-V nor present in the hard-coded BUILT_IN_CMAPS list. pdf.js only knows a fixed set of Adobe CMaps; any other name is rejected before any fetch is attempted, so configuring cMapUrl cannot fix an unknown name.","triggerScenarios":"A PDF font references a CMap name (via /Encoding /Some-Name or a ToUnicode usecmap) that is not in pdf.js's BUILT_IN_CMAPS list - e.g. a custom, third-party, or newer Adobe CMap that this build does not recognize.","commonSituations":"Outdated pdf.js build missing newer Adobe CMap names; a PDF that references a private/non-Adobe CMap; a typo or corruption in the CMap name inside the font dictionary.","solutions":["Update pdf.js to the latest release so BUILT_IN_CMAPS includes more Adobe names.","Repair the PDF so the font uses a standard Adobe CMap that pdf.js recognises.","Catch the error and fall back to a substitute font / no-CID mapping.","If you embed pdf.js in a custom worker, supply a fetchBuiltInCMap that resolves the custom name to your own .bcmap data (still requires the name to be in BUILT_IN_CMAPS, so patching may be needed)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Best-effort: pdf.js does not export BUILT_IN_CMAPS, so wrap the call.\n// If you maintain a fork, export the list and pre-check:\nconst KNOWN = new Set(['Identity-H', 'Identity-V', /* ...Adobe names... */]);\nfunction isKnownCMapName(name) {\n  return KNOWN.has(name);\n}","typeGuard":null,"tryCatchPattern":"try {\n  cmap = await CMapFactory.create({ encoding, fetchBuiltInCMap, useCMap });\n} catch (e) {\n  if (/Unknown CMap name/.test(e.message)) {\n    console.warn('CMap name not bundled, falling back', e);\n    cmap = null;\n  } else throw e;\n}","preventionTips":["Keep pdf.js updated so its BUILT_IN_CMAPS list stays current with Adobe CMaps.","Repair PDFs that reference private/non-standard CMap names.","Treat unknown-CMap failures as non-fatal; fall back to a substitute font.","When generating PDFs, prefer standard Adobe CMap names."],"tags":["cmap","font","cjk","pdf","configuration"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}