Documentation
¶
Overview ¶
Package gofpdi wraps the gofpdi PDF library to import existing PDFs as templates. See github.com/phpdave11/gofpdi for further information and examples.
Users should call NewImporter() to obtain their own Importer instance to work with. To retain backwards compatibility, the package offers a default Importer that may be used via global functions. Note however that use of the default Importer is not thread safe.
Index ¶
- func GetPageSizes() map[int]map[string]map[string]float64
- func ImportPage(f gofpdiPdf, sourceFile string, pageno int, box string) int
- func ImportPageFromStream(f gofpdiPdf, rs *io.ReadSeeker, pageno int, box string) int
- func UseImportedTemplate(f gofpdiPdf, tplid int, x float64, y float64, w float64, h float64)
- type Importer
- func (i *Importer) GetPageSizes() map[int]map[string]map[string]float64
- func (i *Importer) ImportPage(f gofpdiPdf, sourceFile string, pageno int, box string) int
- func (i *Importer) ImportPageFromStream(f gofpdiPdf, rs *io.ReadSeeker, pageno int, box string) int
- func (i *Importer) UseImportedTemplate(f gofpdiPdf, tplid int, x float64, y float64, w float64, h float64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPageSizes ¶
GetPageSizes returns page dimensions for all pages of the imported pdf. Result consists of map[<page number>]map[<box>]map[<dimension>]<value>. <page number>: page number, note that page numbers start at 1 <box>: box identifier, e.g. "/MediaBox" <dimension>: dimension string, either "w" or "h" Note: This uses the default Importer. Call NewImporter() to obtain a custom Importer.
func ImportPage ¶
ImportPage imports a page of a PDF file with the specified box (/MediaBox, /TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id that can be used with UseImportedTemplate to draw the template onto the page. Note: This uses the default Importer. Call NewImporter() to obtain a custom Importer.
func ImportPageFromStream ¶
func ImportPageFromStream(f gofpdiPdf, rs *io.ReadSeeker, pageno int, box string) int
ImportPageFromStream imports a page of a PDF with the specified box (/MediaBox, TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id that can be used with UseImportedTemplate to draw the template onto the page. Note: This uses the default Importer. Call NewImporter() to obtain a custom Importer.
func UseImportedTemplate ¶
UseImportedTemplate draws the template onto the page at x,y. If w is 0, the template will be scaled to fit based on h. If h is 0, the template will be scaled to fit based on w. Note: This uses the default Importer. Call NewImporter() to obtain a custom Importer.
Types ¶
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
Importer wraps an Importer from the gofpdi library.
func NewImporter ¶
func NewImporter() *Importer
NewImporter creates a new Importer wrapping functionality from the gofpdi library.
func (*Importer) GetPageSizes ¶
GetPageSizes returns page dimensions for all pages of the imported pdf. Result consists of map[<page number>]map[<box>]map[<dimension>]<value>. <page number>: page number, note that page numbers start at 1 <box>: box identifier, e.g. "/MediaBox" <dimension>: dimension string, either "w" or "h"
func (*Importer) ImportPage ¶
ImportPage imports a page of a PDF file with the specified box (/MediaBox, /TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id that can be used with UseImportedTemplate to draw the template onto the page.
func (*Importer) ImportPageFromStream ¶
ImportPageFromStream imports a page of a PDF with the specified box (/MediaBox, TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id that can be used with UseImportedTemplate to draw the template onto the page.
func (*Importer) UseImportedTemplate ¶
func (i *Importer) UseImportedTemplate(f gofpdiPdf, tplid int, x float64, y float64, w float64, h float64)
UseImportedTemplate draws the template onto the page at x,y. If w is 0, the template will be scaled to fit based on h. If h is 0, the template will be scaled to fit based on w.