Documentation ¶
Index ¶
- Constants
- type Callback
- type CallbackShipout
- type ColorProfile
- type Hyperlink
- type Object
- type PDFDocument
- func (d *PDFDocument) ClearVTrace(t VTrace)
- func (d *PDFDocument) CreateFont(face *pdf.Face, size bag.ScaledPoint) *font.Font
- func (d *PDFDocument) CreateImage(imgfile *pdf.Imagefile, pagenumber int, box string) *image.Image
- func (d *PDFDocument) Finish() error
- func (pw *PDFDocument) GetNumDest(num int) *pdf.NumDest
- func (d *PDFDocument) IsTrace(t VTrace) bool
- func (d *PDFDocument) LoadColorprofile(filename string) (*ColorProfile, error)
- func (d *PDFDocument) LoadDefaultColorprofile() (*ColorProfile, error)
- func (d *PDFDocument) LoadFace(filename string, index int) (*pdf.Face, error)
- func (d *PDFDocument) LoadFaceFromData(data []byte, index int) (*pdf.Face, error)
- func (d *PDFDocument) LoadImageFile(filename string) (*pdf.Imagefile, error)
- func (d *PDFDocument) LoadImageFileWithBox(filename string, box string, pagenumber int) (*pdf.Imagefile, error)
- func (d *PDFDocument) LoadPatternFile(filename string, langname string) (*lang.Lang, error)
- func (d *PDFDocument) NewPage() *Page
- func (d *PDFDocument) OutputXMLDump(w io.Writer) error
- func (d *PDFDocument) RegisterCallback(cb Callback, fn any)
- func (d *PDFDocument) SetDefaultLanguage(l *lang.Lang)
- func (d *PDFDocument) SetVTrace(t VTrace)
- type Page
- type StructureElement
- type VTrace
Constants ¶
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 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 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 ¶
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) LoadFaceFromData ¶
LoadFaceFromData creates a Face from a byte stream.
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 ¶
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.
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 )