pagetree

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 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 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 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.

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