Documentation
¶
Overview ¶
Package pdffixture writes small, deterministic PDF files for tests and benchmarks.
The files are hand-numbered, uncompressed and use a classic cross-reference table, so a fixture's structure is exactly what its constructor shows and does not depend on the PDF library under test. Every page carries a text marker (the tag, plus " p<N>" for multi-page documents) that independent extractors can read back.
Index ¶
- type Doc
- func Attachment(tag string) *Doc
- func EmptySignatureField(tag string) *Doc
- func FitMarkStreams() *Doc
- func FitMarks(prefix string) *Doc
- func Form(tag string) *Doc
- func ImageRich(tag string, payload int) *Doc
- func LegacyDests(tag string) *Doc
- func Links(tag string) *Doc
- func NamedDests(tag string) *Doc
- func NestedBoxes(tag string) *Doc
- func Outlined(tag string) *Doc
- func PageActions(tag string) *Doc
- func Pages(tag string, count int) *Doc
- func Plain(tag string) *Doc
- func Resource(pages int, label func(index int) string) *Doc
- func SignatureValue(tag string) *Doc
- func Tagged(tag string) *Doc
- func Titled(tag string) *Doc
- func URILink(tag, target, base string, isMap bool) *Doc
- func Versioned(tag, header, catalog string) *Doc
- func WithBoxes(tag string, inherited PageBoxes, own ...PageBoxes) *Doc
- type PageBoxes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Doc ¶
type Doc struct {
// Version is the header version, for example "1.7" or "2.0".
Version string
// Info, when not empty, is the body of a document information dictionary referenced from the trailer.
Info string
// Objs holds the serialized object bodies.
Objs [][]byte
}
Doc is a list of PDF object bodies. Object n is Objs[n-1]; object 1 is always the catalog.
func Attachment ¶
Attachment is a one-page document with an embedded file "note.txt".
func EmptySignatureField ¶ added in v0.2.0
EmptySignatureField is an unsigned PDF with an ordinary unpopulated signature field.
func FitMarkStreams ¶ added in v0.2.0
func FitMarkStreams() *Doc
FitMarkStreams puts a color operator and its following number in separate streams without trailing/leading whitespace. A raw byte join loses the visible blue mark's color.
func FitMarks ¶ added in v0.2.0
FitMarks places blue visible ink and red hidden ink around a 50-point square visible frame. Prefix supplies graphics-state escape controls. The source has a real font resource and text decoys.
func Form ¶
Form is a two-page document ("<tag> p1", "<tag> p2") with an AcroForm: a non-widget parent field "grp" whose two child widgets "a" and "b" sit on different pages, and a merged field/widget "dup". Two Form documents therefore carry the same qualified field names.
func ImageRich ¶
ImageRich is a one-page document marked tag whose page references a DeviceGray image XObject of about payload bytes (a multiple of 1024, at least 1024) of incompressible pseudo-random data seeded from the tag, a stand-in for a scanned page: distinct tags give distinct images, so an optimizer cannot merge them.
func LegacyDests ¶
LegacyDests is NamedDests expressed with the legacy catalog /Dests dictionary and name objects.
func Links ¶
Links is a two-page document ("<tag> p1", "<tag> p2") whose link annotations point directly at the other page, through /Dest and through GoTo actions, forwards and backwards. Every annotation names its own page in /P; page 1 has a direct /Annots array and page 2 an indirect one.
func NamedDests ¶
NamedDests is a two-page document ("<tag> p1", "<tag> p2") with name-tree destinations chap1 and chap2 that link annotations use through /Dest strings and GoTo actions.
func NestedBoxes ¶
NestedBoxes is a two-page document ("<tag> p1", "<tag> p2") in a two-level page tree: the root supplies MediaBox [0 0 612 792], CropBox [50 60 500 700] and Rotate 90; an intermediate node holding page 2 overrides only CropBox with [10 10 300 400].
func Outlined ¶
Outlined is a two-page document ("<tag> p1", "<tag> p2") with an outline, page mode and language.
func PageActions ¶
PageActions is a two-page document ("<tag> p1", "<tag> p2") whose pages carry /AA page-open actions that jump to the other page, and no /Annots.
func Resource ¶
Resource is a generated-pages document: page i shows label(i) on an A4 page when i is even and on a US Letter page when i is odd, all sharing one font object.
func SignatureValue ¶ added in v0.2.0
SignatureValue is a PDF with a populated signature field. Its placeholder value is intentionally not a cryptographically valid signature; it tests refusal of reachable signature state.
func Tagged ¶
Tagged is a one-page document with a structure tree, /MarkInfo and a page /StructParents entry.
func URILink ¶ added in v0.2.0
URILink has one unpainted URI link and an optional catalog URI/Base. Target and base are PDF literal-string contents, allowing tests to exercise escapes without a library serializer.
func Versioned ¶
Versioned is Plain with the given header version and, when catalog is not empty, a catalog /Version.
func WithBoxes ¶
WithBoxes is a document with one page per entry of own ("<tag> p<N>"; a single page when own is empty). The marker sits near the lower-left corner of the MediaBox. Entries of inherited go on the root page-tree node, where pages without their own entry inherit them; UserUnit is not inheritable and is ignored there.
type PageBoxes ¶
type PageBoxes struct {
// Media, Crop are arrays such as "[0 0 612 792]".
Media, Crop string
// Rotate and UserUnit are numbers such as "90" and "2.5".
Rotate, UserUnit string
}
PageBoxes lists page-dictionary entries as PDF source text, so malformed values can be expressed. An empty field omits the entry.