Documentation
¶
Index ¶
- Variables
- func EqualPDFValue(a, b PDFValue) bool
- type Check
- type ContentScanner
- type Cursor
- type Document
- func (d *Document) ClaimedConformance() (part, conformance string, err error)
- func (d *Document) Close() error
- func (d *Document) GetMetadata() (map[string]string, error)
- func (d *Document) GetPageCount() (int, error)
- func (d *Document) GetVersion() (string, error)
- func (d *Document) IsPDFA() (bool, error)
- func (d *Document) ResolveGraph() (PDFValue, error)
- func (d *Document) ResolveGraphByPath(path []string) (PDFValue, error)
- func (d *Document) Verify(t LevelType) (Result, error)
- func (d *Document) VerifyProfile(p *Profile) (Result, error)
- func (d *Document) XMPMetadata() ([]byte, error)
- type FileResult
- type LevelType
- type Lexer
- type PDFArray
- type PDFBoolean
- type PDFDict
- type PDFError
- type PDFHexString
- type PDFInteger
- type PDFName
- type PDFReal
- type PDFRef
- type PDFString
- type PDFValue
- type Profile
- type Result
- type Token
- type TokenType
- type ValidationContext
Constants ¶
This section is empty.
Variables ¶
var Checks checksRegistry
Functions ¶
func EqualPDFValue ¶
Types ¶
type Check ¶
type Check struct {
// contains filtered or unexported fields
}
Check is a named, selectable PDF/A validation rule, identified by a (clause, subclause) pair and grouped into categories under Checks.
func AllChecks ¶
func AllChecks() []Check
AllChecks returns every registered check in catalog order.
func CheckByClause ¶
CheckByClause looks up the registered check for a specific (clause, subclause) pair, e.g. CheckByClause("6.3.4", 1). ok is false if no check is registered for that pair.
func ChecksForClause ¶
ChecksForClause returns every registered check under the given clause (e.g. "6.3.4"), in catalog order.
func (Check) Description ¶
Description returns a human-readable summary of what this check enforces.
type ContentScanner ¶
type ContentScanner struct {
// contains filtered or unexported fields
}
ContentScanner walks a decoded content stream, exposing each operator together with its operands. It reuses the object Lexer for tokenising; bare operators arrive as keyword tokens.
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document represents a PDF file.
func (*Document) ClaimedConformance ¶
ClaimedConformance returns the PDF/A part and conformance level the document's XMP metadata claims (e.g. "1", "B"), read from the pdfaid namespace. This reflects what the file claims, not whether it actually validates — use Verify or IsPDFA to check actual compliance.
func (*Document) GetMetadata ¶
GetMetadata extracts info from the Info dictionary.
func (*Document) GetPageCount ¶
GetPageCount retrieves the page count.
func (*Document) GetVersion ¶
GetVersion extracts the PDF version from the Document header
func (*Document) IsPDFA ¶
IsPDFA reports whether the document is valid PDF/A-1b. It is equivalent to calling Verify(A_1B) and checking the result's Valid field, for callers who only need a yes/no answer.
func (*Document) ResolveGraph ¶
ResolveGraph resolves the PDF object graph, starting from the effective trailer (firstPageTrailer if set, else trailer).
func (*Document) ResolveGraphByPath ¶
ResolveGraphByPath resolves the PDF object graph by path, starting from the effective trailer (firstPageTrailer if set, else trailer).
func (*Document) VerifyProfile ¶
VerifyProfile verifies d against the checks enabled in profile p.
func (*Document) XMPMetadata ¶
XMPMetadata returns the document's raw XMP metadata packet (Root/Metadata), decoded and normalised to UTF-8. It returns an error if the document has no XMP metadata stream, regardless of whether the document otherwise validates as PDF/A.
type FileResult ¶
func VerifyAll ¶
func VerifyAll(paths []string, t LevelType) []FileResult
VerifyAll opens and verifies multiple PDF files concurrently against conformance level t.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer holds the state of the current chunk being parsed.
func (*Lexer) Release ¶
func (l *Lexer) Release()
Release returns l's underlying bufio.Reader to the pool for reuse by a later Lexer. Callers that construct a short-lived Lexer (the common case) should defer Release once the lexer is no longer needed.
func (*Lexer) UnreadToken ¶
type PDFBoolean ¶
type PDFBoolean bool
type PDFDict ¶
type PDFDict struct {
Entries map[string]PDFValue
HasStream bool
// RawStream holds the undecoded bytes of a stream object, retained for
// content-stream and metadata inspection.
RawStream []byte
}
func NewPDFDict ¶
func NewPDFDict() PDFDict
type PDFError ¶
type PDFError struct {
// contains filtered or unexported fields
}
func (PDFError) IsDocumentLevel ¶
IsDocumentLevel reports whether this violation applies to the document as a whole rather than to a specific page.
func (PDFError) ObjectRef ¶
ObjectRef returns the indirect object this violation was reported against, and whether one was recorded. Not every violation is tied to a single object (e.g. file-header or trailer issues), in which case ok is false.
type PDFHexString ¶
type PDFHexString struct{ Value string }
type PDFInteger ¶
type PDFInteger int
type Profile ¶
type Profile struct {
Level LevelType
// SkipUnreachableXObjects, when true, suppresses checks on Form XObjects
// never invoked via Do from a reachable content stream. ISO 19005-1
// (6.2.3.3, 6.2.10) applies to every Form XObject, so Legacy_1B keeps this
// false; PDFA_1B sets it true to match veraPDF's lenient interpretation.
SkipUnreachableXObjects bool
// contains filtered or unexported fields
}
Profile is a mutable set of enabled PDF/A checks for a conformance level, used by VerifyProfile. Mutators (Clear, AddCheck, RemoveCheck) return a new *Profile, leaving the receiver unchanged.
var Legacy_1B *Profile
Legacy_1B is the strict, fully spec-literal PDF/A-1b profile: every check enabled, every Form XObject checked regardless of reachability. Matches the Isartor suite's interpretation, which is stricter than veraPDF's in places.
var PDFA_1B *Profile
PDFA_1B is the default PDF/A-1b profile, tuned to match veraPDF's interpretation of the spec. Used by Verify(A_1B).
func NewProfile ¶
NewProfile returns an empty profile for the given conformance level.
func (*Profile) AddCheck ¶
AddCheck returns a new profile with the given checks added to the enabled set.
func (*Profile) Clear ¶
Clear returns a new profile with the same conformance level but no checks enabled. Behavioral flags (SkipUnreachableXObjects) are preserved.
func (*Profile) RemoveCheck ¶
RemoveCheck returns a new profile with the given checks removed from the enabled set.
type Result ¶
func (Result) Checks ¶
Checks returns the distinct Checks violated in r.Issues, sorted by clause in numeric (dotted-segment) order, e.g. "6.2.9" before "6.2.10", then by subclause.
func (Result) IssuesByCheck ¶
IssuesByCheck groups r.Issues by their violated Check.
func (Result) IssuesForCheck ¶
IssuesForCheck returns the issues that correspond to the given registered Check.
func (Result) IssuesOnPage ¶
IssuesOnPage returns the issues found on the given 1-based page number. Pass 0 to get document-level issues (see PDFError.IsDocumentLevel).
type ValidationContext ¶
type ValidationContext struct {
PageIndex map[int]int
CurrentPage int
// ReachableXObjectPtrs is the set of Entries-map pointers of Form XObjects
// that are actually invoked (via Do) from page or other reachable content
// streams. Nil means unknown (treat everything as reachable).
ReachableXObjectPtrs map[uintptr]bool
// InvisibleOnlyFontPtrs is the set of font dictionary Entries-map pointers
// that are used for text showing exclusively under rendering mode 3 or 7
// (invisible) somewhere in the document, and never under any other mode.
// Such fonts are never actually rendered, so 6.3.3.2 (CIDToGIDMap), 6.3.5
// (glyph coverage) and 6.3.6 (advance width consistency) do not apply.
InvisibleOnlyFontPtrs map[uintptr]bool
// UsedCharCodes maps a simple (non-composite) font's Entries-map pointer
// to the set of single-byte character codes actually passed to a
// text-showing operator somewhere in the document. A subset font's
// CharSet only needs to list glyphs "used for rendering" (6.3.5); a code
// with a non-zero Widths entry that is never actually shown need not be
// present. Nil for a font means no usage info was collected for it.
UsedCharCodes map[uintptr]map[int]bool
// UsedCIDs maps a composite CIDFont's descendant-dict Entries-map pointer
// to the set of CIDs actually passed to a text-showing operator somewhere
// in the document (decoded as 2-byte big-endian codes, valid for the
// Identity-H/Identity-V encodings the verifier can decode). A CID listed
// in the W width array but never shown need not have a glyph in the
// embedded font program (6.3.5); only collected when the font's Encoding
// is Identity-H/V — for any other CMap, usage is left unknown so callers
// fall back to checking every W entry.
UsedCIDs map[uintptr]map[int]bool
// contains filtered or unexported fields
}
func (*ValidationContext) Report ¶
func (ctx *ValidationContext) Report(c Check, obj PDFValue, msg string)
Report records a single violation of c against obj.
func (*ValidationContext) ReportErrs ¶
func (ctx *ValidationContext) ReportErrs(c Check, obj PDFValue, errs []error)
ReportErrs records a violation of c against obj carrying multiple underlying error messages.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
benchmarks
|
|
|
cmd/gopdfrab-bench
command
Command gopdfrab-bench drives the gopdfrab library for benchmarking against other PDF/A verifiers (veraPDF, PDFBox Preflight, a JS validator).
|
Command gopdfrab-bench drives the gopdfrab library for benchmarking against other PDF/A verifiers (veraPDF, PDFBox Preflight, a JS validator). |