{"record":{"id":"ab95767c4b68cad3","repo":"mozilla/pdf.js","slug":"missing-endstream-command","errorCode":null,"errorMessage":"Missing endstream command.","messagePattern":"Missing endstream command\\.","errorType":"exception","errorClass":"FormatError","httpStatus":null,"severity":"error","filePath":"src/core/parser.js","lineNumber":765,"sourceCode":"    // Get the length.\n    let length = dict.get(\"Length\");\n    if (!Number.isInteger(length)) {\n      info(`Bad length \"${length && length.toString()}\" in stream.`);\n      length = 0;\n    }\n\n    // Skip over the stream data.\n    stream.pos = startPos + length;\n    lexer.nextChar();\n\n    // Shift '>>' and check whether the new object marks the end of the stream.\n    if (this.tryShift() && isCmd(this.buf2, \"endstream\")) {\n      this.shift(); // 'stream'\n    } else {\n      // Bad stream length, scanning for endstream command.\n      length = this.#findStreamLength(startPos);\n      if (length < 0) {\n        throw new FormatError(\"Missing endstream command.\");\n      }\n\n      lexer.nextChar();\n      this.shift();\n      this.shift();\n    }\n    this.shift(); // 'endstream'\n\n    stream = stream.makeSubStream(startPos, length, dict);\n    const filter = dict.get(\"F\", \"Filter\");\n    // Streams that explicitly use `/Crypt` are decrypted in the filter chain,\n    // so avoid applying the default stream cipher up-front.\n    if (cipherTransform && !this.#hasCryptFilter(filter)) {\n      stream = cipherTransform.createStream(stream, length);\n    }\n    stream = this.filter(stream, dict, length, cipherTransform);\n    stream.dict = dict;\n    return stream;","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/parser.js#L747-L783","documentation":"Error \"Missing endstream command.\" thrown in mozilla/pdf.js.","triggerScenarios":"Thrown at src/core/parser.js:765 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the stream data ends with an `endstream` keyword; check that the /Length entry of the stream dictionary matches the actual stream data size.","If the PDF is truncated, re-download or regenerate the file so the stream terminates correctly."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}