Documentation
¶
Overview ¶
Package pdfbuild assembles a minimal PDF file from a list of objects, for tests.
It exists for the same reason internal/ttfbuild does, and the reason is the cross-reference table. Numbering objects from 1, recording each one's byte offset, and writing an xref whose entries are ten-digit offsets in the right order is the only real logic in a hand-built fixture — and it is logic a reader has to get right before any test using the file means anything. Copied into a second test package it would be the same defect as arithmetic duplicated in two packages: a fix to one is invisible to the other, and a subtly wrong offset table fails as "pdfcpu could not open this" in a test that is about something else entirely.
Two packages need it: render/native, whose fixtures are streams no producer would emit, and cmd/pdfspec, whose fixtures are font dictionaries no producer would emit.
Not in a _test.go file, because an internal package cannot export from one. Internal so it cannot become part of the module's surface by accident.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bytes ¶
Bytes returns a one-revision PDF whose objects are numbered 1..len(objs) in the order given.
Object 1 is taken as the catalogue, since /Root has to name something and every caller writes it first. Nothing here validates the objects: a fixture's whole purpose is often to be malformed in one specific way, and a builder that rejected that would be useless for the tests that need it most.
Types ¶
This section is empty.