{"record":{"id":"7ae5e7e760f625a8","repo":"mozilla/pdf.js","slug":"unable-to-decode-inline-image-reason","errorCode":null,"errorMessage":"Unable to decode inline image: \"${reason}\".","messagePattern":"Unable to decode inline image: \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/evaluator.js","lineNumber":770,"sourceCode":"          globalColorSpaceCache: this.globalColorSpaceCache,\n          localColorSpaceCache,\n        });\n        // We force the use of RGBA_32BPP images here, because we can't handle\n        // any other kind.\n        imgData = await imageObj.createImageData(\n          /* forceRGBA = */ true,\n          /* isOffscreenCanvasSupported = */ false\n        );\n        operatorList.addImageOps(\n          OPS.paintInlineImageXObject,\n          [imgData],\n          optionalContent\n        );\n      } catch (reason) {\n        const msg = `Unable to decode inline image: \"${reason}\".`;\n\n        if (!ignoreErrors) {\n          throw new Error(msg);\n        }\n        warn(msg);\n      }\n      return;\n    }\n\n    // If there is no imageMask, create the PDFImage and a lot\n    // of image processing can be done here.\n    let objId = `img_${this.idFactory.createObjId()}`,\n      cacheGlobally = false,\n      globalCacheData = null;\n\n    if (this.parsingType3Font) {\n      objId = `${this.idFactory.getDocId()}_type3_${objId}`;\n    } else if (cacheKey && imageRef) {\n      cacheGlobally = this.globalImageCache.shouldCache(\n        imageRef,\n        this.pageIndex","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/evaluator.js#L752-L788","documentation":"Thrown when decoding a small inline image into RGBA fails inside buildPaintImageXObject. The inlining path only runs for tiny images (w+h < 200, no SMask/Mask); any exception from PDFImage construction or createImageData is wrapped into this message. It indicates corrupt or unsupported inline image data.","triggerScenarios":"A content stream contains an inline image (BI...ID...EI) with total w+h under 200 and no mask, whose stream data, filter, or color space cannot be decoded, while ignoreErrors is false.","commonSituations":"Corrupt or truncated PDFs, PDFs produced by buggy generators with malformed inline image filters (e.g. bad Flate/LZW/DCT streams), or rarely-supported color spaces on inline images.","solutions":["Enable ignoreErrors: true in getDocument so the bad inline image is dropped with a warning instead of failing the whole page.","Upgrade PDF.js, since image-decoding fixes land frequently.","Repair or re-export the PDF from a tool that re-encodes inline images.","If you control the PDF, replace inline images with standard XObject images."],"exampleFix":"// before\ngetDocument({ data }); // page render rejects on bad inline image\n\n// after\ngetDocument({ data, ignoreErrors: true }); // image skipped, page still renders","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Inline-image decode errors originate in the worker and cannot be pre-checked.\n// Render defensively and optionally retry with ignoreErrors enabled.\ntry {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (e) {\n  if (/Unable to decode inline image/.test(e.message)) {\n    await reloadWith({ ignoreErrors: true });\n  } else throw e;\n}","preventionTips":["Set ignoreErrors:true when rendering untrusted user-uploaded PDFs.","Keep PDF.js current; inline-image decoding fixes ship regularly.","Log the failing page number so corrupt source PDFs can be re-exported."],"tags":["pdf","image","decoding","inline","malformed-pdf","rendering"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}