...

Package pdfua

Overview ▾

Package pdfua provides PDF/UA (ISO 14289) standard profiles for validating and applying accessibility requirements to PDF documents.

Note that unlike PDF/A, applying a PDF/UA profile can only fix mechanical issues (identification metadata, viewer preferences, catalog entries). Semantic requirements - a complete and correct structure tree, alternate descriptions, reading order - must be authored, e.g. with creator.TagComponents. ApplyStandard returns an error when the document lacks the semantic foundation it cannot synthesize.

type Profile

Profile is the model.StandardImplementer enhanced by PDF/UA part information.

type Profile interface {
    model.StandardImplementer
    Part() int
}

type Profile1

Profile1 is the implementation of the PDF/UA-1 (ISO 14289-1) standard profile. Implements model.StandardImplementer, Profile interfaces.

type Profile1 struct {
    // contains filtered or unexported fields
}

func NewProfile1

func NewProfile1(options *Profile1Options) *Profile1

NewProfile1 creates a new Profile1 with given options.

func (*Profile1) ApplyStandard

func (p *Profile1) ApplyStandard(document *docutil.Document) error

ApplyStandard applies the mechanical subset of PDF/UA-1 requirements to the document. It cannot synthesize semantics: if the document is not a tagged PDF (no StructTreeRoot), an error is returned.

func (*Profile1) Part

func (p *Profile1) Part() int

Part gets the PDF/UA part.

func (*Profile1) StandardName

func (p *Profile1) StandardName() string

StandardName gets the name of the standard.

func (*Profile1) ValidateStandard

func (p *Profile1) ValidateStandard(r *model.CompliancePdfReader) error

ValidateStandard checks if the input CompliancePdfReader matches the PDF/UA-1 standard.

Known limitations (may yield false negatives): font checks (embedding/ToUnicode, 7.21.4.1-1, 7.21.7-1) inspect page resources only, so a font used solely inside a Form XObject is not seen (content tagging, 7.1-3, does descend into Form XObjects); ParentTree/MCID cross-reference validity is not verified. See the scope comment at the top of verifiers.go for the full list of deferred rules.

type Profile1Options

Profile1Options are the options for the PDF/UA-1 profile.

type Profile1Options struct {
    // DefaultLanguage is set as the catalog Lang entry by ApplyStandard when
    // the document defines none. Ignored when empty.
    DefaultLanguage string
    // Xmp is the xmp options information.
    Xmp XmpOptions
}

func DefaultProfile1Options

func DefaultProfile1Options() *Profile1Options

DefaultProfile1Options are the default options for the Profile1.

type Profile2

Profile2 implements the PDF/UA-2 (ISO 14289-2) standard profile.

type Profile2 struct {
    // contains filtered or unexported fields
}

func NewProfile2

func NewProfile2(options *Profile2Options) *Profile2

NewProfile2 creates a new Profile2 with the given options.

func (*Profile2) ApplyStandard

func (p *Profile2) ApplyStandard(document *docutil.Document) error

ApplyStandard applies the mechanical subset of PDF/UA-2 requirements.

func (*Profile2) Part

func (p *Profile2) Part() int

Part gets the PDF/UA part.

func (*Profile2) StandardName

func (p *Profile2) StandardName() string

StandardName gets the name of the standard.

func (*Profile2) ValidateStandard

func (p *Profile2) ValidateStandard(r *model.CompliancePdfReader) error

ValidateStandard checks if the input matches the PDF/UA-2 standard.

type Profile2Options

Profile2Options are the options for the PDF/UA-2 profile.

type Profile2Options struct {
    // DefaultLanguage is set as the catalog Lang entry by ApplyStandard when
    // the document defines none. Ignored when empty.
    DefaultLanguage string
    // Xmp is the xmp options information.
    Xmp XmpOptions
}

func DefaultProfile2Options

func DefaultProfile2Options() *Profile2Options

DefaultProfile2Options are the default options for Profile2.

type VerificationError

VerificationError is the PDF/UA verification error containing all violated rules.

type VerificationError struct {
    // ViolatedRules are the rules that were violated during verification.
    ViolatedRules []ViolatedRule
    // Part defines the PDF/UA part (1 or 2) on which verification failed.
    Part int
}

func (VerificationError) Error

func (v VerificationError) Error() string

Error implements error interface.

type ViolatedRule

ViolatedRule defines a violated PDF/UA rule. RuleNo follows the clause numbering of ISO 14289 (e.g. "7.1-3").

type ViolatedRule struct {
    RuleNo string
    Detail string
}

func (ViolatedRule) String

func (v ViolatedRule) String() string

String gets a string representation of the violated rule.

type XmpOptions

XmpOptions are the options used when writing the PDF/UA XMP metadata.

type XmpOptions struct {
    // Copyright information.
    Copyright string
    // MarshalIndent defines marshaling indent of the XMP metadata.
    MarshalIndent string
    // MarshalPrefix defines marshaling prefix of the XMP metadata.
    MarshalPrefix string
}