{"record":{"id":"348fc71bf1324da4","repo":"mozilla/pdf.js","slug":"invalid-object-offset-in-the-objstm-stream-offs","errorCode":null,"errorMessage":"invalid object offset in the ObjStm stream: ${offset}","messagePattern":"invalid object offset in the ObjStm stream: (.+?)","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/xref.js","lineNumber":985,"sourceCode":"    }\n    let parser = new Parser({\n      lexer: new Lexer(stream),\n      xref: this,\n      allowStreams: true,\n    });\n    const nums = new Array(n);\n    const offsets = new Array(n);\n    // read the object numbers to populate cache\n    for (let i = 0; i < n; ++i) {\n      const num = parser.getObj();\n      if (!Number.isInteger(num)) {\n        throw new FormatError(\n          `invalid object number in the ObjStm stream: ${num}`\n        );\n      }\n      const offset = parser.getObj();\n      if (!Number.isInteger(offset)) {\n        throw new FormatError(\n          `invalid object offset in the ObjStm stream: ${offset}`\n        );\n      }\n      nums[i] = num;\n\n      // The entry in the xref table is the object number followed by the index.\n      // So if index (gen number) is not the same as the index (i), we fix it\n      // (fixes bug 1978317).\n      const entry = this.getEntry(num);\n      if (entry?.offset === tableOffset && entry.gen !== i) {\n        entry.gen = i;\n      }\n\n      offsets[i] = offset;\n    }\n\n    const start = (stream.start || 0) + first;\n    const entries = new Array(n);","sourceCodeStart":967,"sourceCodeEnd":1003,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/xref.js#L967-L1003","documentation":"A FormatError raised in the same ObjStm header-parsing loop as 223, but for the offset member of each (objectNumber, offset) pair: the offset read from the stream is not an integer. Without valid integer offsets, pdf.js cannot locate each compressed object inside the stream. The offending value is shown in the message.","triggerScenarios":"Same family as 223: truncated, reordered, or decrypted-garbage ObjStm content where the offset token fails to parse as an integer.","commonSituations":"Truncated downloads, faulty PDF generators, deflate corruption, post-decryption byte misalignment.","solutions":["Ensure the full file was downloaded (compare to Content-Length / re-fetch).","Rebuild object streams with qpdf --object-streams=generate or mutool clean.","Catch FormatError per page and degrade gracefully.","Re-export from the source application if you own it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await doc.getPage(n);\n} catch (e) {\n  if (e instanceof pdfjsLib.FormatError) continue;\n  throw e;\n}","preventionTips":["Pre-validate downloads against expected size/hash.","Repair with qpdf/mutool before processing.","Isolate per-page errors so one corrupt object stream does not fail everything."],"tags":["objstm","corruption","parsing","format-error"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}