import { ImageFormat } from '../enum'; import { _PdfCrossReference, PdfPage, Rectangle } from '@syncfusion/ej2-pdf'; import { PdfRedactionRegion } from '../redaction/pdf-redaction-region'; /** * Internal PDF image helper that decodes, colors, resizes, and exports image data. * * @private */ export declare class _PdfImage { private image; private width; private height; private interpolate; private imageMask; private matte; private bpc; private colorSpace; private numComps; private decode; private needsDecode; private decodeCoefficients; private decodeAddends; private smask; /** * Optional callback surface and platform details usable for canvas operations. * * @private */ _canvasRenderCallback: any; /** * Preferred output image format for encoding. * * @private */ _imageFormat: ImageFormat; private imageResizer; private mask; private jpxDecoderOptions; forceRgba: boolean; forceRgb: boolean; /** * Page-relative bounds used for redaction mapping. * * @private */ _bounds: number[]; /** * Page reference used for redaction mapping. * * @private */ _page: PdfPage; /** * Redaction regions to process against this image. * * @private */ _options: PdfRedactionRegion[]; /** * Indicates whether the image has intersections with any redaction region. * * @private */ _isIntersect: boolean; /** * Initializes the image from the given PDF image stream/dictionary, resolving color space, masks, and dimensions. * * @private * @param {any} xref Cross-reference for object fetching. * @param {any} image Source image stream or wrapper. * @param {boolean} isInline Whether the image is inline. * @param {any} callBack Canvas/platform callback provider. * @param {any} [smask] Optional soft mask stream. * @param {any} [mask] Optional hard mask stream or range. * @param {boolean} [isMask] Whether this call initializes an image mask. * @returns {Promise} Resolves to the current `_PdfImage` instance. * @throws {FormatError} When required image dimensions are invalid. */ _initializeFromImage(xref: any, image: any, isInline: boolean, callBack: any, // eslint-disable-line smask?: any, mask?: any, isMask?: boolean): Promise; /** Resizes a single-channel buffer using nearest-neighbor sampling. * * @private * @param {Uint8Array | Uint16Array | Uint32Array} src Source mask buffer. * @param {number} bpc Bits per component. * @param {number} w1 Source width. * @param {number} h1 Source height. * @param {number} w2 Target width. * @param {number} h2 Target height. * @returns {Uint8Array | Uint16Array | Uint32Array} Resized buffer with same component width. */ _resizeImageMask(src: Uint8Array | Uint16Array | Uint32Array, bpc: number, w1: number, h1: number, w2: number, h2: number): Uint8Array | Uint16Array | Uint32Array; /** * Determines whether the current decode array is default for masks when color space is not resolved. * * @private * @returns {boolean} `true` if decode map is default otherwise, `false`. */ _isDefaultDecode(): boolean; /** * Retrieves image raw data bytes based on the underlying stream type. * * @private * @param {number} length Expected number of bytes to read. * @param {any} decoderOptions Decoder options and image context. * @returns {any} Raw bytes buffer or decoded result depending on stream type. */ _getImageData(length: number, decoderOptions: any): any; /** * Creates RGBA/RGB image data for drawing/encoding; handles color conversion, decode array, smask/mask, resize, and export. * * @private * @param {boolean} [forceRGBA=false] If `true`, allocate RGBA output even without masks. * @param {boolean} [isOffscreenCanvasSupported=false] If `true`, use canvas to encode/export when available. * @returns {Promise} Image data or encoded bytes depending on environment and options. */ _createImageData(forceRGBA?: boolean, isOffscreenCanvasSupported?: boolean): Promise; /** * Maps an `ImageFormat` value to a canvas MIME type string. * * @private * @param {ImageFormat} format Target image format. * @returns {string} Canvas MIME string for encoding. */ _findImageFormat(format: ImageFormat): string; /** * Builds a `_PdfImage` from a raw image stream, wiring SMask/Mask entries. * * @private * @param {_PdfCrossReference} xref Cross-reference. * @param {any} image Source image stream. * @param {boolean} isInline Whether inline. * @param {any} callBack Canvas/platform callback. * @returns {Promise<_PdfImage>} The initialized `_PdfImage`. */ _buildImage(xref: _PdfCrossReference, image: any, isInline: boolean, callBack: any): Promise<_PdfImage>; /** * Creates an 8-bit per channel alpha mask for 1bpp mask streams. * * @private * @param {any} image Source mask stream. * @param {boolean} isOffscreenCanvasSupported Whether canvas export is available. * @returns {any} Encoded bytes or raw buffer depending on environment. * @throws {FormatError} When an unknown mask format is provided. */ _createMask(image: any, isOffscreenCanvasSupported: boolean): any; readonly drawWidth: number; readonly drawHeight: number; /** * Applies the decode array mapping in-place to the provided buffer. * * @private * @param {Uint8Array} buffer Component buffer to transform. * @returns {void} nothing. */ _decodeBuffer(buffer: Uint8Array): void; /** * Expands packed/bpc component data into a typed array with one value per component. * * @private * @param {Uint8Array} buffer Packed source buffer. * @returns {Uint8Array | Uint16Array | Uint32Array} Expanded component buffer. */ _getComponents(buffer: Uint8Array): Uint8Array | Uint16Array | Uint32Array; /** * Fills the alpha channel for RGBA output using SMask/Mask or default opaque alpha. * * @private * @param {Uint8ClampedArray} rgbaBuf Target RGBA buffer. * @param {number} width Output width. * @param {number} height Output height. * @param {number} actualHeight Actual populated rows. * @param {Uint8ClampedArray} image Component buffer. * @returns {Promise} Resolves when alpha is filled. * @throws {FormatError} On unknown mask formats. */ _fillOpacity(rgbaBuf: Uint8ClampedArray, width: number, height: number, actualHeight: number, image: Uint8ClampedArray): Promise; /** * Reverses matte preblend from smask+matte to restore unblended RGB. * * @private * @param {Uint8ClampedArray} buffer RGBA buffer in-place. * @param {number} width Image width. * @param {number} height Effective height to process. * @returns {void} nothing. */ _undoPreblend(buffer: Uint8ClampedArray, width: number, height: number): void; /** * Fills a gray buffer from the image data. * * @private * @param {Uint8ClampedArray} buffer Output grayscale buffer . * @returns {Promise} Resolves when gray values are computed. * @throws {FormatError} If called for non-grayscale images. */ _fillGrayBuffer(buffer: Uint8ClampedArray): Promise; /** * Composes a bitmap from raw pixel data using canvas, and returns encoded bytes. * * @private * @param {any} kind Image kind `imageKind.rgba32BPP` or `imageKind.rgb24BPP`. * @param {number} width Image width. * @param {number} height Image height. * @param {Uint8ClampedArray} src Pixel data. * @returns {Promise} Encoded image bytes. * @throws {Error} If no canvas is available from the callback. */ _createBitmap(kind: any, width: number, height: number, src: Uint8ClampedArray): Promise; /** * Returns a transferable image handle if the environment provides one. * * @private * @returns {any} Transferable bitmap or `null` if not available. */ _getTransferableImage(): any; /** * Wraps a transferable bitmap into an image-like object for direct consumption. * * @private * @param {number} width Image width. * @param {number} height Image height. * @returns {any} Image wrapper with `bitmap`, `width`, `height`, and `interpolate` or `null` if not available. */ _getImage(width: number, height: number): any; /** * Reads and returns image bytes, optionally decoding JPX via worker/processor or returning Flate/DecodeStream bytes. * * @private * @param {number} length Number of bytes to read. * @param {any} options Decode and draw options. * @returns {Promise} Raw or decoded image bytes. */ _getImageBytes(length: number, { drawWidth, drawHeight, forceRGBA, forceRGB, internal }: { drawWidth?: number; drawHeight?: number; forceRGBA?: boolean; forceRGB?: boolean; internal?: boolean; }): Promise; /** * Applies region-based redaction to the canvas image data in-place. * * @private * @param {any} canvasImgData Canvas `ImageData` to redact. * @returns {void} nothing. */ _processImageRedaction(canvasImgData: any): void; /** * Computes the intersection rectangle of two rectangles. * * @private * @param {Rectangle} a First rectangle. * @param {Rectangle} b Second rectangle. * @returns {any} The intersection rectangle or `null` when disjoint. */ _intersect(a: Rectangle, b: Rectangle): any; /** * Applies a white fill over the specified rectangle on the image data. * * @private * @param {ImageData} imageData Canvas image data to modify. * @param {number} x Left position. * @param {number} y Top position. * @param {number} w Width of the rectangle. * @param {number} h Height of the rectangle. * @returns {void} nothing. */ _applyRedaction(imageData: ImageData, x: number, y: number, w: number, h: number): void; } /** * Represents the application platform type. * * ```typescript * // Load an existing PDF document * let document: PdfDocument = new PdfDocument(data); * // Define a canvas render callback that returns a canvas element and the application platform. * const canvasRenderCallback = (): {canvas: any, applicationPlatform: ApplicationPlatform} => { * const canvas = document.createElement('canvas'); * return { canvas: canvas, applicationPlatform: ApplicationPlatform.vue }; * }; * // Initialize a new instance of the `PdfDataExtractor` class * let extractor: PdfDataExtractor = new PdfDataExtractor(document, callBack: canvasRenderCallback); * // Extract collection of `PdfEmbeddedImage` from the PDF document. * let imageInfoCollection: PdfEmbeddedImage[] = extractor.extractImages({ startPageIndex: 0, endPageIndex: document.pageCount - 1}); * let imageInfo: PdfEmbeddedImage = imageInfoCollection[0]; * let data: Uint8Array = imageInfo.data; * // Destroy the documents * document.destroy(); */ export declare enum ApplicationPlatform { /** * Specifies the `typeScript` platform. */ typescript = "typescript", /** * Specifies the `javascript` platform. */ javascript = "javascript", /** * Specifies the `angular` platform. */ angular = "angular", /** * Specifies the `react` platform. */ react = "react", /** * Specifies the `vue` platform. */ vue = "vue", /** * Specifies the `aspnetcore` platform. */ aspnetcore = "aspnetcore", /** * Specifies the `aspnetmvc` platform. */ aspnetmvc = "aspnetmvc" }