import { PDFDocument } from 'pdf-lib'; import type { ResolvedImageLayout } from '../core'; /** Where an image goes: the page size, and the drawn rectangle on it. */ export interface ImagePlacement { pageWidth: number; pageHeight: number; x: number; y: number; width: number; height: number; } /** * Work out the page size and the drawn rectangle for an image of the given * pixel dimensions. Pure, so it can be tested exactly. * * - `fit: 'page'`: the page is `layout.pageSize`, turned to match the image's * orientation (a square image keeps the size as given). The image is scaled * down to fit inside the margins, never enlarged, and centered. * - `fit: 'natural'`: the page is the image at one pixel per point, scaled * down only if a side would exceed the PDF format's 14400-point maximum. */ export declare function computeImagePlacement(imageWidth: number, imageHeight: number, layout: ResolvedImageLayout): ImagePlacement; /** * Render one raster image as a one-page PDF, placed according to `layout` * (see `computeImagePlacement` and `MergeOptions.image`). The image's pixels * are embedded unchanged at full resolution; only the displayed size varies. * * @throws {PdfMergeError} when the image's header declares more than * `maxPixels` pixels (decompression-bomb / page-size guard; see * `MergeOptions.maxImagePixels`). * @throws {InvalidPdfFormatError} when the bytes are not a decodable PNG/JPEG. */ export declare function imageToDocument(bytes: Uint8Array, format: 'png' | 'jpg', index: number, maxPixels: number, layout: ResolvedImageLayout): Promise;