UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

90 lines (89 loc) 3.06 kB
import { _ImageDecoder } from './image-decoder'; import { _PdfStream } from './../../base-stream'; import { _PdfDictionary } from './../../pdf-primitives'; /** * JPEG image decoder that parses the input stream, extracts width/height/components * from JPEG headers, and exposes a PDF image dictionary (DCTDecode). * * @private */ export declare class _JpegDecoder extends _ImageDecoder { /** * Initializes a new instance of the `_JpegDecoder` class. * * @private * @param {Uint8Array} stream byte array. */ constructor(stream: Uint8Array); /** * Gets the raw image data buffer read from the source stream. * * @private * @returns {ArrayBuffer} The image data as a contiguous buffer. */ readonly _imageDataAsNumberArray: ArrayBuffer; /** * Initializes decoder state for a JPEG stream: sets format, reads header to resolve * image properties, resets the cursor, and copies the full stream into `_imageData`. * * @private * @returns {void} */ _initialize(): void; /** * Parses the JPEG header to determine image dimensions and component count. * Falls back to a streaming marker scan when the initial segment lengths exceed bounds. * * @private * @returns {void} */ _readHeader(): void; /** * Builds PDF image stream for the decoded JPEG, wiring the * appropriate dictionary entries `Type`, `Subtype`, `Width`, `Height`, `BitsPerComponent`, * `Filter=DCTDecode`, `ColorSpace`, and `DecodeParms`. * * @private * @returns {_PdfStream} The populated PDF image stream. */ _getImageDictionary(): _PdfStream; /** * Resolves the PDF color space name from the number of JPEG components. * * @private * @returns {string} Returns `'DeviceGray'` for 1 component, `'DeviceCMYK'` for 4 components, otherwise `'DeviceRGB'`. */ _getColorSpace(): string; /** * Produces a `DecodeParms` dictionary suitable for DCTDecode images with predictor settings. * * @private * @returns {_PdfDictionary} The decode parameters dictionary. */ _getDecodeParams(): _PdfDictionary; /** * Skips over a JPEG segment by reading its 2 byte length and advancing the cursor. * Throws if the segment length is invalid. * * @private * @returns {void} * @throws {Error} If the segment length is less than 2. */ _skipStream(): void; /** * Scans the JPEG stream by markers to locate a Start of Frame (SOF) segment and * extracts height, width, and component count when the standard header walk exceeded bounds. * * @private * @returns {void} */ _readExceededJpegImage(): void; /** * Reads the next JPEG marker (0xFF followed by a non-FF byte), skipping fill bytes. * * @private * @returns {number} The 16 bit marker value. * @throws {Error} If non marker bytes were skipped prior to 0xFF (invalid stream). */ _getMarker(): number; }