document

package
v0.0.0-...-3435f2a Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// OneCM has the width of one centimeter in ScaledPoints
	OneCM bag.ScaledPoint = 1857685
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback int

Callback represents the type of callback to register.

const (
	// CallbackPreShipout is called right before a page shipout. It is called once for each page.
	CallbackPreShipout Callback = iota
)

type CallbackShipout

type CallbackShipout func(page *Page)

CallbackShipout gets called before the shipout process starts.

type ColorProfile

type ColorProfile struct {
	Identifier string
	Registry   string
	Info       string
	Condition  string
	Colors     int
	// contains filtered or unexported fields
}

ColorProfile represents a color profile

func (*ColorProfile) String

func (cp *ColorProfile) String() string
type Hyperlink struct {
	URI   string
	Local string
	// contains filtered or unexported fields
}

A Hyperlink represents a clickable thing in the PDF.

type Object

type Object struct {
	X     bag.ScaledPoint
	Y     bag.ScaledPoint
	Vlist *node.VList
}

Object contains a vertical list and coordinates to be placed on a page.

type PDFDocument

type PDFDocument struct {
	Author               string
	Bleed                bag.ScaledPoint
	ColorProfile         *ColorProfile
	CompressLevel        uint
	Creator              string
	CreationDate         time.Time
	CurrentPage          *Page
	DefaultLanguage      *lang.Lang
	DefaultPageHeight    bag.ScaledPoint
	DefaultPageWidth     bag.ScaledPoint
	Faces                []*pdf.Face
	Filename             string
	Keywords             string
	Languages            map[string]*lang.Lang
	Pages                []*Page
	PDFWriter            *pdf.PDF
	RootStructureElement *StructureElement
	ShowCutmarks         bool
	ShowHyperlinks       bool
	Spotcolors           []*color.Color
	Subject              string
	SuppressInfo         bool
	Title                string
	ViewerPreferences    map[string]string
	// contains filtered or unexported fields
}

PDFDocument contains all references to a document

func NewDocument

func NewDocument(w io.Writer) *PDFDocument

NewDocument creates an empty document.

func (*PDFDocument) ClearVTrace

func (d *PDFDocument) ClearVTrace(t VTrace)

ClearVTrace removes the visual tracing.

func (*PDFDocument) CreateFont

func (d *PDFDocument) CreateFont(face *pdf.Face, size bag.ScaledPoint) *font.Font

CreateFont returns a new Font object for this face at a given size.

func (*PDFDocument) CreateImage

func (d *PDFDocument) CreateImage(imgfile *pdf.Imagefile, pagenumber int, box string) *image.Image

CreateImage returns a new Image derived from the image file. The parameter pagenumber is honored only in PDF files. The Box is one of "/MediaBox", "/CropBox", "/TrimBox", "/BleedBox" or "/ArtBox"

func (*PDFDocument) Finish

func (d *PDFDocument) Finish() error

Finish writes all objects to the PDF and writes the XRef section. Finish does not close the writer.

func (*PDFDocument) GetNumDest

func (pw *PDFDocument) GetNumDest(num int) *pdf.NumDest

GetNumDest returns the PDF destination object with the internal number.

func (*PDFDocument) IsTrace

func (d *PDFDocument) IsTrace(t VTrace) bool

IsTrace returns true if tracing t is set

func (*PDFDocument) LoadColorprofile

func (d *PDFDocument) LoadColorprofile(filename string) (*ColorProfile, error)

LoadColorprofile loads an icc based color profile from the URL.

func (*PDFDocument) LoadDefaultColorprofile

func (d *PDFDocument) LoadDefaultColorprofile() (*ColorProfile, error)

LoadDefaultColorprofile load the default ISOcoated_v2_eci.icc color profile

func (*PDFDocument) LoadFace

func (d *PDFDocument) LoadFace(filename string, index int) (*pdf.Face, error)

LoadFace loads a font from a TrueType or OpenType collection.

func (*PDFDocument) LoadFaceFromData

func (d *PDFDocument) LoadFaceFromData(data []byte, index int) (*pdf.Face, error)

func (*PDFDocument) LoadImageFile

func (d *PDFDocument) LoadImageFile(filename string) (*pdf.Imagefile, error)

LoadImageFile loads an image file. Images that should be placed in the PDF file must be derived from the file. For PDF files this defaults to the /MediaBox and page 1.

func (*PDFDocument) LoadImageFileWithBox

func (d *PDFDocument) LoadImageFileWithBox(filename string, box string, pagenumber int) (*pdf.Imagefile, error)

LoadImageFileWithBox loads an image file. Images that should be placed in the PDF file must be derived from the file.

func (*PDFDocument) LoadPatternFile

func (d *PDFDocument) LoadPatternFile(filename string, langname string) (*lang.Lang, error)

LoadPatternFile loads a hyphenation pattern file.

func (*PDFDocument) NewPage

func (d *PDFDocument) NewPage() *Page

NewPage creates a new Page object and adds it to the page list in the document. The CurrentPage field of the document is set to the page.

func (*PDFDocument) OutputXMLDump

func (d *PDFDocument) OutputXMLDump(w io.Writer) error

OutputXMLDump writes an XML dump of the document to w.

func (*PDFDocument) RegisterCallback

func (d *PDFDocument) RegisterCallback(cb Callback, fn any)

RegisterCallback registers the callback in fn.

func (*PDFDocument) SetDefaultLanguage

func (d *PDFDocument) SetDefaultLanguage(l *lang.Lang)

SetDefaultLanguage sets the document default language.

func (*PDFDocument) SetVTrace

func (d *PDFDocument) SetVTrace(t VTrace)

SetVTrace sets the visual tracing

type Page

type Page struct {
	Height            bag.ScaledPoint
	Width             bag.ScaledPoint
	ExtraOffset       bag.ScaledPoint
	Background        []Object
	Objects           []Object
	Userdata          map[any]any
	Finished          bool
	StructureElements []*StructureElement
	Annotations       []pdf.Annotation
	Spotcolors        []*color.Color
	Objectnumber      pdf.Objectnumber
	// contains filtered or unexported fields
}

A Page struct represents a page in a PDF file.

func (*Page) OutputAt

func (p *Page) OutputAt(x bag.ScaledPoint, y bag.ScaledPoint, vlist *node.VList)

OutputAt places the nodelist at the position.

func (*Page) Shipout

func (p *Page) Shipout()

Shipout places all objects on a page and finishes this page.

type StructureElement

type StructureElement struct {
	ID         int
	Role       string
	ActualText string

	Parent *StructureElement
	Obj    *pdf.Object
	// contains filtered or unexported fields
}

StructureElement represents a tagged PDF element such as H1 or P.

func (*StructureElement) AddChild

func (se *StructureElement) AddChild(cld *StructureElement)

AddChild adds a child element (such as a span in a paragraph) to the element given with se. AddChild sets the parent pointer of the child.

type VTrace

type VTrace int

VTrace determines the type of visual tracing

const (
	// VTraceImages shows bounding box of images
	VTraceImages VTrace = iota
	// VTraceVBoxes shows the bounding box of vlists
	VTraceVBoxes
	// VTraceHBoxes shows the bounding box of hlists
	VTraceHBoxes
	// VTraceHyperlinks shows hyperlinks
	VTraceHyperlinks
	// VTraceDest shows destinations
	VTraceDest
)

Jump to

Keyboard shortcuts

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