mozilla/pdf.js · error · FormatError
Base font is not specified
Error message
Base font is not specified
What it means
Thrown by translateFont() when a non-composite, non-Type3 font has no /FontDescriptor AND its /BaseFont entry is not a Name. This is a legacy-compatibility path (pre-PDF-1.5 base-14 fonts like Helvetica did not require a FontDescriptor), where PDF.js falls back to synthesizing a descriptor from the BaseFont name; if even that name is missing or not a Name, the font is unrecoverable. The guard precedes normalizeFontName() which would otherwise crash on a non-string.
Source
Thrown at src/core/evaluator.js:4482
if (!descriptor) {
if (isType3Font) {
// FontDescriptor is only required for Type3 fonts when the document
// is a tagged pdf.
descriptor = Dict.empty;
} else if (composite) {
// Some PDFs omit the FontDescriptor on the descendant CIDFont when
// referencing one of the standard Acrobat CJK fonts via a predefined
// CMap (e.g. /Encoding /90ms-RKSJ-H with /BaseFont /HeiseiMin-W3).
// Fall through so the CMap is loaded by the composite-font path
// below; otherwise multi-byte codes would be decoded byte-by-byte.
descriptor = Dict.empty;
} else {
// Before PDF 1.5 if the font was one of the base 14 fonts, having a
// FontDescriptor was not required.
// This case is here for compatibility.
let baseFontName = dict.get("BaseFont");
if (!(baseFontName instanceof Name)) {
throw new FormatError("Base font is not specified");
}
// Using base font name as a font name.
baseFontName = normalizeFontName(baseFontName.name);
const metrics = this.getBaseFontMetrics(baseFontName);
// Simulating descriptor flags attribute
const fontNameWoStyle = baseFontName.split("-", 1)[0];
const flags =
(this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) |
(metrics.monospace ? FontFlags.FixedPitch : 0) |
(getSymbolsFonts()[fontNameWoStyle]
? FontFlags.Symbolic
: FontFlags.Nonsymbolic);
const properties = {
type,
name: baseFontName,View on GitHub (pinned to 5903d58d58)
Solutions
- Re-export the PDF from the source application or through Ghostscript to populate /BaseFont and /FontDescriptor.
- If authoring, always include /BaseFont as a Name on every font dictionary.
- Isolate the failing page with stopAtErrors: true and continue rendering others.
- If the document opens in Acrobat, file a PDF.js bug — additional fallback heuristics may be possible.
Defensive patterns
Strategy: try-catch
Try / catch
try {
await page.render({ canvasContext, viewport });
} catch (e) {
if (e.name === 'FormatError' && /Base font is not specified/.test(e.message)) {
// legacy font has neither descriptor nor BaseFont — use fallback
} else throw e;
} Prevention
- Always include /BaseFont as a Name on every font dictionary, even legacy base-14 fonts.
- Add a /FontDescriptor to avoid relying on the legacy fallback path entirely.
- Re-export old PDFs through a modern exporter to populate missing metadata.
When it happens
Trigger: A simple (non-Type0, non-Type3) font dictionary with no /FontDescriptor and a /BaseFont that is missing, null, a string, or any non-Name object. Fires during translateFont() in the font-load path.
Common situations: Older or minimalist PDF producers that omit FontDescriptor and also fail to declare BaseFont as a Name. Also seen in heavily stripped/subset PDFs where optimization removed the BaseFont. Rare; typically indicates a seriously malformed font dictionary.
Related errors
- Invalid entry in 'Differences' array: ${data}
- Encoding is not a Name nor a Dict
- Max size of CID is 65,535
- invalid font Subtype
- Descendant fonts are not specified
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/38758abc351900f1.
Report an issue: GitHub.