{"record":{"id":"1a4802074ef69c58","repo":"mozilla/pdf.js","slug":"built-in-cmap-parameters-are-not-provided","errorCode":null,"errorMessage":"Built-in CMap parameters are not provided.","messagePattern":"Built-in CMap parameters are not provided\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/cmap.js","lineNumber":682,"sourceCode":"    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 {\n  static async create({ encoding, fetchBuiltInCMap, useCMap }) {\n    if (encoding instanceof Name) {\n      return createBuiltInCMap(encoding.name, fetchBuiltInCMap);","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/cmap.js#L664-L700","documentation":"Thrown by createBuiltInCMap when the fetchBuiltInCMap argument is falsy. The library needs a callback to load the binary .bcmap files for any non-Identity built-in CMap; without it, resolving a Name-encoded CMap is impossible. Usually the evaluator supplies this callback, but only when cMapUrl is configured.","triggerScenarios":"Calling CMapFactory.create({ encoding: Name, fetchBuiltInCMap: null }) directly, or running the worker without cMapUrl configured so PartialEvaluator never builds a fetcher and passes undefined through.","commonSituations":"Embedding pdf.js without setting cMapUrl/cMapPacked in getDocument; node.js usage that constructs the evaluator manually; a stripped-down build that omits the standard CMap loading path.","solutions":["Pass cMapUrl and cMapPacked: true to getDocument, pointing at the bundled cmaps/ directory from pdfjs-dist.","If using a custom worker setup, supply a fetchBuiltInCMap(name) callback returning { cMapData: ArrayBuffer, isCompressed: boolean }.","For node, install pdfjs-dist and point cMapUrl at its cmaps/ folder (e.g. node_modules/pdfjs-dist/cmaps/)."],"exampleFix":"// before\ngetDocument({ url }); // no CMap config -> CJK fonts fail\n\n// after\ngetDocument({\n  url,\n  cMapUrl: '/node_modules/pdfjs-dist/cmaps/',\n  cMapPacked: true,\n});","handlingStrategy":"validation","validationCode":"// Ensure a fetcher is configured before loading a CMap-dependent PDF\nfunction buildFetchBuiltInCMap(cMapUrl, cMapPacked) {\n  if (!cMapUrl) return null;\n  return async (name) => {\n    const suffix = cMapPacked ? '.bcmap' : '';\n    const cMapData = await fetch(`${cMapUrl}${name}${suffix}`).then(r => r.arrayBuffer());\n    return { cMapData, isCompressed: cMapPacked };\n  };\n}","typeGuard":"function hasCMapFetcher(opts) {\n  return typeof opts.fetchBuiltInCMap === 'function'\n    || (typeof opts.cMapUrl === 'string' && opts.cMapUrl.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Always pass cMapUrl (and cMapPacked: true) to getDocument for documents that may use CID/CJK fonts.","When calling CMapFactory.create directly, pass a non-null fetchBuiltInCMap callback.","For node.js, point cMapUrl at node_modules/pdfjs-dist/cmaps/.","Add a smoke-test that loads a CJK sample PDF in CI to catch missing CMap config."],"tags":["cmap","font","cjk","configuration","pdf","worker"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}