HomeUniDoc
...

Package sanitize

Overview ▾

type SanitizationOpts

SanitizationOpts specifies the objects to be removed during sanitization.

type SanitizationOpts struct {
    // JavaScript specifies wether JavaScript action should be removed. JavaScript Actions, section 12.6.4.16 of PDF32000_2008
    JavaScript bool

    // URI specifies if URI actions should be removed. 12.6.4.7 URI Actions, PDF32000_2008.
    URI bool

    // GoToR removes remote GoTo actions. 12.6.4.3 Remote Go-To Actions, PDF32000_2008.
    GoToR bool

    // GoTo specifies wether GoTo actions should be removed. 12.6.4.2 Go-To Actions, PDF32000_2008.
    GoTo bool

    // RenditionJS enables removing of `JS` entry from a Rendition Action.
    // The `JS` entry has a value of text string or stream containing a JavaScript script that shall be executed when the action is triggered.
    // 12.6.4.13 Rendition Actions Table 214, PDF32000_2008.
    RenditionJS bool

    // OpenAction removes OpenAction entry from the document catalog.
    OpenAction bool

    // Launch specifies wether Launch Action should be removed.
    // A launch action launches an application or opens or prints a document.
    // 12.6.4.5 Launch Actions, PDF32000_2008.
    Launch bool
}

type Sanitizer

Sanitizer represents a sanitizer object. It implements the Optimizer interface to access the objects field from the writer.

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

func New

func New(opts SanitizationOpts) *Sanitizer

New returns a new sanitizer object.

func (*Sanitizer) GetSuspiciousObjects

func (s *Sanitizer) GetSuspiciousObjects() map[string]int

GetSuspiciousObjects returns a count of each detected suspicious object.

func (*Sanitizer) Optimize

func (sanitizer *Sanitizer) Optimize(objects []core.PdfObject) ([]core.PdfObject, error)

Optimize optimizes `objects` and returns updated list of objects.