Skip to content

PDF/A documents ​

PDF/A is the archiving version of PDF: a set of ISO rules that keep a document readable for decades, such as embedded fonts and no external content. In this guide you compress a PDF/A file with Hyper Compress in one of two ways: keep it conformant, or compress it fully and let Hyper withdraw its PDF/A claim.

Either way, Hyper never leaves a file that claims to be PDF/A after a change that may have broken the rules.

Before you begin ​

  • Hyper installed for at least one surface. See the Quickstart.
  • A PDF/A file, saved as input.pdf.
  • Decide what the output is for:
    • It goes into an archive or a system that checks PDF/A: keep it conformant (step 2).
    • It is a copy for reading or email: compress fully (step 3).

1. See what Hyper detects ​

Hyper reads the PDF/A claim from the file's XMP metadata, the pdfaid:part and pdfaid:conformance entries that PDF/A files carry. It trusts the claim and does not validate the file against the standard.

Every result reports the input's claim:

SurfaceFieldExampleNo claim
Node.js, WebAssemblypdfa{ part: 2, conformance: 'b' }null
HTTPX-Pdfa2bempty
CLInone

conformance is lower case, and empty for levels without a letter, such as plain PDF/A-4. The CLI does not print the claim; use the HTTP API, Node.js or WebAssembly when you need it.

2. Keep the file conformant ​

Set preserveConformance. Over HTTP, preservePdfa=true does the same.

bash
hyper input.pdf output.pdf --set preserveConformance=true
js
import { compress } from 'hyper-compress';

const result = await compress({
  sourcePath: 'input.pdf',
  savePath: 'output.pdf',
  options: { preserveConformance: true },
});
console.log(result.pdfa, result.pdfaPreserved, result.warnings);
bash
curl -s -o output.pdf -D - --data-binary @input.pdf \
  'http://localhost:8080/api/compress?preservePdfa=true' | grep -i '^x-'
js
import { readFile, writeFile } from 'node:fs/promises';
import { compress } from 'hyper-compress-wasm';

const input = new Uint8Array(await readFile('input.pdf'));
const result = await compress(input, { options: { preserveConformance: true } });
await writeFile('output.pdf', result.data);
console.log(result.pdfa, result.pdfaOutcome, result.warnings);

From Node.js you see:

text
{ conformance: 'b', part: 2 } true []

The output keeps its PDF/A claim, and Hyper skipped every step that could break the standard. preserveConformance has no effect on a file that does not claim PDF/A, so it is safe to set for every file.

What preserving switches off ​

For a PDF/A input, preserveConformance changes your options before the run. Some changes come with a warning, because you asked for something Hyper did not do. The others are silent, because a preset turns them on by default.

OptionSwitched off forWarning
rasterizePagesevery levelrasterizePages disabled to preserve PDF/A conformance
brotlievery levelbrotli disabled to preserve PDF/A conformance
removeMetadataevery levelremoveMetadata refused: PDF/A requires the XMP metadata packet
colorTarget (set back to original)every levelcolorTarget ignored to preserve PDF/A conformance
linearizeevery levellinearize skipped to preserve PDF/A conformance
minVersion 2.0 (set back to none)PDF/A-1, 2 and 3minVersion 2.0 refused: this PDF/A level requires a 1.x header
removeStandardFonts, unembedAliasedFontsevery levelnone
removeOutputIntentsevery levelnone
flattenIccevery levelnone
preferJpx, subsetFontsPDF/A-1none
removeStructTreelevel A (1a, 2a, 3a)none

Preserving also changes how Hyper runs:

  • The engine runs in its PDF/A mode. speed: 'quality', for example, does not try JPEG 2000.
  • The repack step that rewrites the file's structure is skipped.
  • The PDF version in the file header stays as it was. minVersion can still raise it within the 1.x range, or to 2.0 for PDF/A-4.
  • A size target is not searched. Hyper runs once and metTarget says whether that result fits. On a miss the warning says so: target of <n> bytes not reached: <m> bytes; no size search runs while preserving PDF/A, so turn off preserveConformance to let Hyper go further.

As always, if the result is not smaller, you get your original bytes.

3. Compress fully and withdraw the claim ​

Leave preserveConformance off. Hyper then applies every option you ask for, including the preset's defaults such as flattenIcc, and then removes the PDF/A claim from the output.

bash
hyper input.pdf output.pdf
js
import { compress } from 'hyper-compress';

const result = await compress({ sourcePath: 'input.pdf', savePath: 'output.pdf' });
console.log(result.pdfa, result.pdfaPreserved);
bash
curl -s -o output.pdf -D - --data-binary @input.pdf \
  'http://localhost:8080/api/compress' | grep -i '^x-pdfa'
js
import { readFile, writeFile } from 'node:fs/promises';
import { compress } from 'hyper-compress-wasm';

const input = new Uint8Array(await readFile('input.pdf'));
const result = await compress(input);
await writeFile('output.pdf', result.data);
console.log(result.pdfa, result.pdfaOutcome);

From Node.js you see:

text
{ conformance: 'b', part: 2 } false

pdfa still shows the input's claim. pdfaPreserved: false says the output no longer claims PDF/A.

WARNING

Without preserveConformance, the output is an ordinary PDF. Do not send it to a system that requires PDF/A.

What happens depends on the result:

ResultOutputNode.js pdfaPreserved, HTTP X-Pdfa-PreservedWebAssembly pdfaOutcome
The file got smallerThe compressed file, with the PDF/A entries removed from its XMP metadata. The rest of the metadata stays.falseclaim-withdrawn
Hyper could not make it smallerYour original bytes, with their valid claimtruepreserved
The claim could not be removedYour original bytes, with the warning belowtruepreserved

When the claim cannot be removed, or the file without the claim is not smaller than the original, Hyper keeps the original and warns, with the real level filled in:

text
the PDF/A-2b claim could not be removed from the compressed file, so the original was kept; set preserveConformance to compress it as PDF/A

Reading the outcome ​

SurfaceKept as PDF/AClaim withdrawn
Node.jspdfaPreserved: truepdfaPreserved: false
WebAssemblypdfaOutcome: 'preserved'pdfaOutcome: 'claim-withdrawn'
HTTPX-Pdfa-Preserved: trueX-Pdfa-Preserved: false
CLIno indicator

pdfaOutcome is none when the input does not claim PDF/A. pdfaPreserved and X-Pdfa-Preserved are false in that case, so read them together with pdfa or X-Pdfa. A signed PDF/A file comes back untouched, so it counts as preserved.

Differences between PDF/A parts ​

PartWhat Hyper does differently while preserving
PDF/A-1 (1a, 1b)Also keeps preferJpx and subsetFonts off. Refuses minVersion 2.0.
PDF/A-2 and PDF/A-3 (2a, 2b, 2u, 3a, 3b, 3u)Refuses minVersion 2.0.
PDF/A-4 (4, 4e, 4f)Allows minVersion 2.0, because PDF/A-4 is based on PDF 2.0.
Level A (1a, 2a, 3a)Keeps the structure tree: removeStructTree stays off, because level A requires tagging.

Troubleshooting ​

A system rejects the output as not PDF/A. You compressed without preserveConformance, so the claim was withdrawn. Run again with --set preserveConformance=true or preservePdfa=true.

The file barely shrank with preserveConformance. Several steps that save space, such as flattening colour profiles and the repack, are switched off. That is the cost of keeping the standard. Compare with a run without it to see the difference for your file.

Hyper does not detect a file as PDF/A. The file has no pdfaid entries in its XMP metadata, so Hyper treats it as an ordinary PDF. A file that only looks like PDF/A, without the claim, gets no special handling.

Next steps ​

Dual-licensed under AGPL-3.0 and Commercial License.