pagetree

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Overview

Package pagetree implements PDF page trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindPages added in v0.4.0

func FindPages(r pdf.Getter) ([]pdf.Reference, error)

FindPages returns a list of all pages in the document. The returned list contains the references to the page dictionaries.

func GetPage added in v0.3.3

func GetPage(r pdf.Getter, pageNo int) (pdf.Dict, error)

GetPage returns the page tree node for a given page number. Page numbers start at 0. Inheritable attributes are copied from the parent nodes. The /Parent attribute is removed from the returned dictionary.

func NumPages added in v0.3.3

func NumPages(r pdf.Getter) (int, error)

Types

type Iterator added in v0.4.0

type Iterator struct {
	Err error
	// contains filtered or unexported fields
}

func NewIterator added in v0.4.0

func NewIterator(r pdf.Getter) *Iterator

func (*Iterator) All added in v0.4.0

func (i *Iterator) All() func(yield func(pdf.Reference, pdf.Dict) bool) bool

All returns a function which iterates over all pages in the document. The arguments are the reference to the page dictionary and the page dictionary itself.

The function must return true if the iteration should continue, or false if it should stop.

TODO(voss): change this to iterate over (page number, page dictionary) pairs?

type Writer

type Writer struct {
	Out pdf.Putter
	// contains filtered or unexported fields
}

Writer writes a page tree to a PDF file.

func NewWriter

func NewWriter(w pdf.Putter) *Writer

NewWriter creates a new page tree which adds pages to the PDF document w.

func (*Writer) AppendPage

func (w *Writer) AppendPage(pageDict pdf.Dict) error

AppendPage adds a new page to the page tree.

This function takes ownership of the pageDict object, and adds the /Parent entry before writing the object to the PDF file.

func (*Writer) AppendPageRef added in v0.3.0

func (w *Writer) AppendPageRef(ref pdf.Reference, pageDict pdf.Dict) error

AppendPageRef adds a new page to the page tree, using the given reference for the page dictionary.

This function takes ownership of the pageDict object, and adds the /Parent entry before writing the object to the PDF file.

func (*Writer) Close

func (w *Writer) Close() (pdf.Reference, error)

Close closes the current tree and all subtrees. After a tree has been closed, no more pages can be added.

If the tree is the root of a page tree, the complete tree is written to the PDF file and a reference to the root node is returned. Otherwise, the returned reference is nil.

TODO(voss): get rid of the Reference return value

func (*Writer) NewRange added in v0.3.4

func (w *Writer) NewRange() (*Writer, error)

NewRange creates a new Writer that can insert pages into a PDF document at position position current at the time of the call. Pages added to the parent Writer will be inserted after the pages from the newly returned Writer.

func (*Writer) NextPageNumber

func (w *Writer) NextPageNumber(cb func(int))

NextPageNumber registers a callback that will be called when the absolute page number of the next page to be added is known. Page numbers are relative to the start of the document, starting at 0.

The callback will be called with -1 if the page tree is closed before another page is added.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL