Resource and Image Optimization

HotPDF can reduce loaded-document size without changing page graphics-state semantics or breaking inherited resources and annotation appearances

Content and resource consolidation

Repeated inline images can become shared image XObjects after occurrence and payload thresholds are met

Unused page resource names are removed conservatively after scanning page content, nested Form XObjects and annotation appearance streams

Compatible page content streams are decoded, joined with safe token boundaries and normalized to a single Flate stream

Form XObjects and embedded fonts are deduplicated from canonical decoded content and recursively canonical resource graphs, with compatible font subset prefixes normalized during comparison

Loaded-font subsetting

SubsetLoadedFonts traces character codes through page content, nested Form XObjects and annotation appearance streams, resolves each code through the PDF font encoding and CID mapping, then retains only reachable glyph programs

Font dictionaries, CID maps, widths and ToUnicode data keep their existing identifiers because TrueType, CFF and Type 1 subsetting preserves glyph IDs or glyph names; shared embedded programs aggregate usage from every compatible font dictionary before one rewrite

TrueType composite and COLR v0/v1 outline dependencies are closed recursively while color, bitmap, variation and shaping tables remain intact; Type 1 PFB, split binary and hex PFA programs preserve used CharStrings and replace unused entries with valid equal-length endchar programs

The operation skips an entire font program when any used code cannot be mapped, adopts only a smaller raw or Flate candidate, and refuses signed documents by default so callers must explicitly opt in to signature invalidation

Image policies

JPEG recompression selects eligible color spaces, output quality and minimum byte savings

JPEG 2000 optimization supports lossless and visually lossless profiles, optional tiles and all five progression orders through an explicit non-disabled profile

Visual-cost recompression evaluates bounded JPEG or JPEG 2000 quality trials against the decoded source, rejects candidates outside the perceptual-error or minimum-savings limits, and selects the lowest weighted visual-error and byte-cost score with deterministic tie-breaking

JBIG2 global data is shared only when the exact decoded global segment bytes match under jbspExactGlobalsOnly

Effective-DPI downsampling follows page and nested Form matrices, decodes color-managed source pixels and resamples soft masks with their owning images

Image rewriting color converts supported ICCBased, CalGray and CalRGB inputs to calibrated RGB, while unsupported calibrated inputs remain untouched instead of being converted to process RGB

DownsampleLoadedImages resizes supported 8-bit raw, Flate, LZW, ASCII and RunLength Separation or DeviceN images directly in component space, preserving the exact color-space graph, tint transform, colourants, /Decode ranges and overprint semantics

DCT, JPX, JBIG2 and CCITT spot images remain unchanged when their codec cannot expose original plate samples

Use loaded-page color rewrite when the required output is a uniform Gray, RGB, or CMYK process space across vector paint, images, patterns, shadings, transparency, and ICC resources

Adaptive object streams

Object-stream packing can bound member size, target container bytes and member count while preserving object-number locality and excluding dirty objects that are likely to change again

Enabling adaptive packing also requests the required PDF version, xref stream and full rewrite

Primary APIs