Skip to content

Options ​

Every option Hyper accepts. All surfaces take the same names and values. Pass only the options you want to change: everything you leave out comes from the preset (medium when you name none).

bash
hyper input.pdf output.pdf --preset high --set grayscale=true --set imageQuality=40
js
import { compress } from 'hyper-compress';

await compress({
  sourcePath: 'input.pdf',
  savePath: 'output.pdf',
  preset: 'high',
  options: { grayscale: true, imageQuality: 40 },
});
bash
curl -o output.pdf --data-binary @input.pdf \
  --url-query 'preset=high' \
  --url-query 'options={"grayscale":true,"imageQuality":40}' \
  'http://localhost:8080/api/compress'
js
import { readFile, writeFile } from 'node:fs/promises';
import { compress } from 'hyper-compress-wasm';

const result = await compress(new Uint8Array(await readFile('input.pdf')), {
  preset: 'high',
  options: { grayscale: true, imageQuality: 40 },
});
await writeFile('output.pdf', result.data);

How values are read ​

  • Numbers outside the allowed range are clamped to the nearest end, and decimals are rounded.
  • Choices (colorTarget, mrc and the like) fall back to their default when the value is not one of the listed ones.
  • Booleans must be true or false; anything else falls back to the default.
  • Unknown names are ignored, so check the spelling if a setting seems to do nothing.

A bad option never fails a run. To see exactly what will run, call resolveOptions in the Node.js SDK.

The medium column below is what you get when you set nothing. Preset values at the end lists all four presets. The guides explain when to change what.

Images ​

OptionTypemediumWhat it does
imageQualitynumber 5 to 10050JPEG quality for re-encoded images. Lower is smaller with more visible artefacts. Below about 20 the artefacts are obvious, which is why no preset goes there, but a size target can.
maxDpinumber 0 to 600150Colour and grayscale images above this resolution are resampled down. 0 leaves resolution alone. Shorthand for maxDpiColor and maxDpiGray; 1-bit images have their own limit, maxDpiMono.
maxDpiColornumber 0 to 6000Resolution limit for colour images. 0 uses maxDpi.
maxDpiGraynumber 0 to 6000Resolution limit for grayscale images. 0 uses maxDpi.
maxDpiMononumber 0 to 12000Resolution limit for 1-bit (black and white) images such as text scans. 0 leaves them at full resolution, because 1-bit text loses legibility quickly; 300 is a safe value. Downsampled 1-bit images stay 1-bit.
thresholdDpinumber 0 to 24000Only resample images above this resolution. 0 keeps the built-in rule: lossy images are resampled once they exceed the limit, lossless ones once they exceed it by half. Values below the limit act as the limit, so an image is never scaled up.
forceDownsamplebooleanfalseResample every image above the limit, even one only slightly above it. By default lossless images are left alone until they exceed the limit by half, because resampling them buys little.
losslessbooleanfalseTurns off quality, resolution, colour conversion, ICC profile flattening and every other lossy image step. Images are only stored more efficiently, so every pixel stays the same. A size target that the lossless result misses switches the search to lossy encoding.
grayscalebooleanfalseConvert images to grayscale. Page text and vector colours are left alone; use colorTarget gray to convert those too.
colorTargetoriginal, rgb, cmyk, grayoriginalConvert the document to one colour model. rgb and cmyk convert images and page text and vector colours through ICC profiles (sRGB and a generic CMYK profile); pure grays and pure black map to K-only in CMYK. gray converts images, text and vectors to grayscale. Spot colours (Separation and DeviceN), patterns and shadings are kept. An image is only converted when the result is not larger, and if the converted file ends up larger than the original, the original is returned with a warning. Ignored when lossless and while preserving PDF/A.
jpegSubsamplingauto, 444, 422, 420autoChroma subsampling for re-encoded JPEG images. auto lets the encoder decide (full colour resolution); 420 halves colour resolution both ways and is smallest; 422 halves it horizontally; 444 keeps it. Ignored when lossless.
jpegProgressivebooleanfalseWrite progressive JPEG images, which appear gradually while loading over slow connections. Usually a little smaller too.
speedquality, balanced, fastbalancedHow many encodings are tried per image. fast encodes JPEG only, with no JPEG 2000 trial and no palette trials. balanced runs the trials the other options ask for. quality also tries JPEG 2000 (except in PDF/A) and lossy and lossless palettes for every image and keeps the smallest. Ignored when lossless.
reduceColorbooleantrueStore images with few colours as palette (indexed) images, which are much smaller than full colour. Only images that look the same afterwards are converted.
clipImagesbooleantrueCrop image data hidden outside the visible clip region.
preferJpxbooleantrueLet JPEG 2000 compete with JPEG per image and keep the smaller one.
removeAlternatesbooleanfalseRemove alternate versions of images, such as high resolution copies kept for printing. Viewers show the main image either way.
flattenIccbooleantrueReplace embedded ICC colour profiles of 2 KB or more on page content with the matching plain colour space (gray, RGB or CMYK). Saves the profile bytes; colours can shift slightly where the profile differed from the standard one.
mrcoff, auto, forceoffMixed raster content for scanned pages: each page image is split into a sharp 1-bit text mask, a low-resolution background and a low-resolution ink colour layer. auto applies it to pages made of one or two page-sized images and no visible text; force applies it to every page. Every rewritten page is rendered before and after and rolled back if it changed visibly. Ignored when lossless.
mrcBackgroundDpinumber 36 to 30075Resolution of the MRC background and ink colour layers. The text mask keeps the scan resolution, up to 300 dpi.
mrcBackgroundQualitynumber 5 to 10030JPEG quality of the MRC background layer.
mrcForegroundQualitynumber 5 to 10050JPEG quality of the MRC ink colour layer.
mrcDetectPhotosbooleantrueFind photographic regions on MRC pages and keep them out of the 1-bit text mask, so photos are stored as a separate image layer at the background resolution instead of being broken into black specks.
jbig2SymbolsbooleanfalseStore repeated shapes in black and white images once and reuse them across pages (lossy JBIG2). Smaller scans, but a shape can be swapped for a similar one, so a page is kept only when every small area matches the original. Off keeps black and white images exact.

Rasterization ​

For image-only documents such as scans and print-to-PDF output. Unless you also set rasterizeText, Hyper refuses to rasterize when any page contains text, including an invisible OCR layer, so it cannot destroy searchable text; the skip is reported as a warning. Rasterization is also disabled while preserving PDF/A. See Scanned documents.

OptionTypemediumWhat it does
rasterizePagesbooleanfalseReplace each page with a single rendered image. Shrinks vector-heavy pages dramatically.
rasterizeDpinumber 36 to 600150Render resolution. Higher keeps more detail.
rasterizeQualitynumber 1 to 10050JPEG quality for the rasterized pages.
rasterizeTextbooleanfalseRasterize pages even when the document has a text layer. Text stops being selectable and searchable, and links stop working. Needs rasterizePages.

Fonts ​

OptionTypemediumWhat it does
subsetFontsbooleantrueKeep only the glyphs the document uses. Lossless: the text looks and searches the same.
removeStandardFontsbooleanfalseUnembed the standard 14 PDF fonts (Times, Helvetica, Courier, Symbol and ZapfDingbats in their styles); every viewer has them built in.
unembedAliasedFontsbooleanfalseUnembed metric-compatible clones of the standard fonts. Arial, Times New Roman and Courier New map to the built-in equivalents. Only applied when safe.
mergeFontsbooleantrueMerge duplicate font programs and font dictionaries, and with them duplicate objects and resources, so each is stored once.

Structure and interactivity ​

OptionTypemediumWhat it does
annotationskeep, flatten, removekeepWhat happens to comments, highlights, stamps and other markup annotations. keep leaves them; flatten draws them into the page so they can no longer be edited; remove deletes them. Form fields and links are never touched by this option; see flattenForms and flattenLinks.
removeAnnotsbooleanfalseDeprecated, use annotations. true behaves like annotations flatten, which is what it always did.
removeBookmarksbooleanfalseRemove the bookmarks (outline) panel.
removeActionsbooleanfalseRemove JavaScript and other actions that run code or open things: the open action, document, page and annotation triggers, document-level scripts, and JavaScript, launch, import, submit and media actions on links and bookmarks. Plain links and bookmark jumps keep working.
removeNamedDestsbooleanfalseRemove the named destinations table. Links, bookmarks and the open action that point at a named destination are rewritten to point at the page directly first, so they keep working. Links from other documents to a name in this one stop working.
removeAttachmentsbooleanfalseRemove embedded files, both document attachments and file attachment annotations.
removeSignatureAppearancesbooleanfalseRemove the visible appearance of empty (unsigned) signature fields. Signed documents are returned untouched unless removeSignatures is set.
flattenFormsbooleanfalseFlatten form fields into page content. Form fields stop being fillable.
flattenLinksbooleanfalseDraw link annotations into the page. Links stop being clickable; any visible link border stays on the page.
removeSignaturesbooleanfalseRemove digital signatures so a signed document can be compressed instead of returned untouched. The visible signature stays on the page, but the file is no longer signed and can be signed again.
removeStructTreebooleanfalseDrop the structure tree. Removes tagging, which screen readers rely on.
removeThreadsbooleanfalseRemove article threads, the reading order chains some magazines and newspapers use to jump between columns.

Metadata and cleanup ​

OptionTypemediumWhat it does
removeThumbnailsbooleantrueRemove embedded page thumbnails.
removeAppDatabooleantrueRemove application private data (PieceInfo) that programs like Illustrator store to reopen the file for editing. Viewers never use it.
removeSpiderInfobooleanfalseRemove web capture information (SpiderInfo) left by tools that converted web pages to PDF.
removeOutputIntentsbooleanfalseRemove output intents, which tell a printer which colour profile the document was prepared for. Needed for PDF/A and PDF/X; kept while preserving PDF/A.
removeMetadatabooleanfalseRemove the document information (title, author, producer, dates and custom entries) and the document XMP metadata packet. Refused with a warning while preserving PDF/A, which requires XMP.
removePrintSettingsbooleanfalseRemove print presets (scaling, duplex, paper tray, page range, copies). Other viewer preferences stay.
removeSearchIndexbooleanfalseRemove web capture content identifiers (the IDS and URLS name trees).

Output format ​

OptionTypemediumWhat it does
preserveConformancebooleanfalseKeep a PDF/A document conformant. Disables every step that would break the standard, including Brotli and rasterization; anything dropped is reported in warnings.
contentPrecisionnumber 0 to 86Number precision when page content is rewritten compactly. 0 keeps every value exactly. 3 to 8 rounds coordinates to that many significant digits (always keeping at least 3 decimals, so no value moves by more than 0.0005 units) and colours to 3 decimals. Ignored when lossless.
linearizebooleanfalseLinearize the output (fast web view), so a browser can show the first page before the whole file has downloaded. Adds a little size. Skipped for signed documents, which are returned untouched, and while preserving PDF/A.
minVersionnone, 1.4, 1.5, 1.6, 1.7, 2.0noneMinimum PDF version of the output. A lower header version is raised; a higher one is never lowered. 2.0 is refused while preserving PDF/A-1, 2 or 3, which require a 1.x header.
brotlibooleanfalsePDF 2.0 Brotli stream compression. Smaller files, but the reader must support it (MuPDF 1.26+, Ghostscript 10.06+, Firefox). Off while preserving PDF/A.

Preset values ​

What each preset sets, field by field. A preset is a complete set of options; start from one and override any field.

Optionlowmediumhighlossless
imageQuality805020100
maxDpi200150720
maxDpiColor0000
maxDpiGray0000
maxDpiMono001500
thresholdDpi0000
forceDownsamplefalsefalsefalsefalse
losslessfalsefalsefalsetrue
grayscalefalsefalsefalsefalse
colorTargetoriginaloriginaloriginaloriginal
jpegSubsamplingautoautoautoauto
jpegProgressivefalsefalsefalsefalse
speedbalancedbalancedbalancedbalanced
reduceColortruetruetruetrue
clipImagesfalsetruetruefalse
preferJpxtruetruetruefalse
removeAlternatesfalsefalsetruefalse
flattenIcctruetruetruefalse
mrcoffoffoffoff
mrcBackgroundDpi75757575
mrcBackgroundQuality30303030
mrcForegroundQuality50505050
mrcDetectPhotostruetruetruetrue
jbig2Symbolsfalsefalsefalsefalse
rasterizePagesfalsefalsefalsefalse
rasterizeDpi150150150150
rasterizeQuality50505050
rasterizeTextfalsefalsefalsefalse
subsetFontstruetruetruetrue
removeStandardFontsfalsefalsetruefalse
unembedAliasedFontsfalsefalsetruefalse
mergeFontstruetruetruetrue
annotationskeepkeepkeepkeep
removeAnnotsfalsefalsefalsefalse
removeBookmarksfalsefalsefalsefalse
removeActionsfalsefalsefalsefalse
removeNamedDestsfalsefalsefalsefalse
removeAttachmentsfalsefalsefalsefalse
removeSignatureAppearancesfalsefalsefalsefalse
flattenFormsfalsefalsefalsefalse
flattenLinksfalsefalsefalsefalse
removeSignaturesfalsefalsefalsefalse
removeStructTreefalsefalsefalsefalse
removeThreadsfalsefalsetruefalse
removeThumbnailstruetruetruetrue
removeAppDatatruetruetruetrue
removeSpiderInfofalsefalsetruefalse
removeOutputIntentsfalsefalsefalsefalse
removeMetadatafalsefalsefalsefalse
removePrintSettingsfalsefalsefalsefalse
removeSearchIndexfalsefalsefalsefalse
preserveConformancefalsefalsefalsefalse
contentPrecision6660
linearizefalsefalsefalsefalse
minVersionnonenonenonenone
brotlifalsefalsefalsefalse

Dual-licensed under AGPL-3.0 and Commercial License.