{"record":{"id":"f3602b6a61567b8b","repo":"mozilla/pdf.js","slug":"required-maxp-table-is-not-found","errorCode":null,"errorMessage":"Required \"maxp\" table is not found","messagePattern":"Required \"maxp\" table is not found","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/fonts.js","lineNumber":2799,"sourceCode":"      delete tables[\"cvt \"];\n      this.isOpenType = true;\n    } else {\n      if (!tables.loca) {\n        throw new FormatError('Required \"loca\" table is not found');\n      }\n      if (!tables.glyf) {\n        warn('Required \"glyf\" table is not found -- trying to recover.');\n        // Note: We use `sanitizeGlyphLocations` to add dummy glyf data below.\n        tables.glyf = {\n          tag: \"glyf\",\n          data: new Uint8Array(0),\n        };\n      }\n      this.isOpenType = false;\n    }\n\n    if (!tables.maxp) {\n      throw new FormatError('Required \"maxp\" table is not found');\n    }\n\n    let numGlyphsFromCFF;\n    if (parsedCff) {\n      try {\n        parsedCff.duplicateFirstGlyph();\n        tables[\"CFF \"].data = new CFFCompiler(parsedCff).compile();\n        numGlyphsFromCFF = parsedCff.charStringCount;\n      } catch {\n        warn(\"Failed to compile font \" + properties.loadedName);\n      }\n    }\n\n    font.pos = (font.start || 0) + tables.maxp.offset;\n    let version = font.getInt32();\n    const numGlyphs = numGlyphsFromCFF ?? font.getUint16();\n    if (version === 0x00005000 && tables.maxp.length !== 6) {\n      tables.maxp.data = tables.maxp.data.subarray(0, 6);","sourceCodeStart":2781,"sourceCodeEnd":2817,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/fonts.js#L2781-L2817","documentation":"Thrown when the font's table directory lacks a 'maxp' (Maximum Profile) table. The maxp table is mandatory in both TrueType and OpenType fonts — it stores the number of glyphs, memory requirements, and other limits. Without it, the font processor cannot determine numGlyphs or validate table sizes.","triggerScenarios":"After the TrueType/CFF branching logic, the check if (!tables.maxp) at line 2798 throws. This applies to both TrueType and OpenType/CFF fonts that reach this point (CFF fonts that have complete head/hhea/maxp/post continue here rather than diverting to this.convert()).","commonSituations":"A severely truncated or corrupt font file missing core tables. A font file that is not actually a valid OpenType/TrueType file but was embedded as one. Fonts stripped of mandatory tables by aggressive optimization tools. A font offset table pointing to invalid table locations.","solutions":["Replace the corrupt font with a complete, valid font file.","Rebuild the font with fonttools to regenerate all mandatory tables including maxp.","Validate the PDF's embedded font stream is not truncated — check its stream length against the actual data.","If the font is embedded in the PDF, extract it and verify with ots-sanitize."],"exampleFix":"# extract and validate embedded font from PDF\n# using fonttools + mutool\nmutool extract broken.pdf   # extract embedded fonts\nfrom fontTools import ttLib\nfont = ttLib.TTFont('extracted.ttf')  # raises on missing maxp\n# replace with a valid font and re-embed","handlingStrategy":"validation","validationCode":"// Server-side: verify font has maxp table\n// from fontTools import ttLib\n// font = ttLib.TTFont('font.ttf')\n// assert 'maxp' in font, 'Font missing maxp table'\n","typeGuard":null,"tryCatchPattern":"try {\n  await page.render(renderParams).promise;\n} catch (err) {\n  if (err.message?.includes('Required \"maxp\" table is not found')) {\n    console.error('Font missing maxp table; replace with valid font.');\n  } else { throw err; }\n}","preventionTips":["Always validate embedded fonts include all mandatory OpenType tables before embedding.","Use ots-sanitize — it flags missing maxp as a critical error.","Rebuild fonts with fonttools to ensure all required tables are present."],"tags":["font","maxp-table","required-table","truetype","opentype","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}