Documentation
¶
Index ¶
- Variables
- type Align
- type Color
- type Document
- func (d *Document) AddPage(size ...PageSize) *Page
- func (d *Document) Bytes() ([]byte, error)
- func (d *Document) Circle(x, y, r float64) *Document
- func (d *Document) Clip() *Document
- func (d *Document) Close() error
- func (d *Document) ClosePath() *Document
- func (d *Document) CurveTo(x1, y1, x2, y2, x3, y3 float64) *Document
- func (d *Document) Dash(pattern []float64, phase float64) *Document
- func (d *Document) Err() error
- func (d *Document) Fill() *Document
- func (d *Document) FillAndStroke() *Document
- func (d *Document) FillColor(c Color) *Document
- func (d *Document) FillEvenOdd() *Document
- func (d *Document) FillShading(name string) *Document
- func (d *Document) Font(name string) *Document
- func (d *Document) FontSize(size float64) *Document
- func (d *Document) HasLiveImportSource() bool
- func (d *Document) Image(name string, x, y, w, h float64) *Document
- func (d *Document) ImageFile(path string, x, y, w, h float64) *Document
- func (d *Document) LineCap(style int) *Document
- func (d *Document) LineJoin(style int) *Document
- func (d *Document) LineTo(x, y float64) *Document
- func (d *Document) LineWidth(w float64) *Document
- func (d *Document) LinearGradient(x1, y1, x2, y2 float64, stops []GradientStop) string
- func (d *Document) List(items []string, opts ...TextOptions) *Document
- func (d *Document) Merge(other *Document) error
- func (d *Document) MergeFiles(paths ...string) error
- func (d *Document) MoveDown(lines float64) *Document
- func (d *Document) MoveTo(x, y float64) *Document
- func (d *Document) Opacity(alpha float64) *Document
- func (d *Document) Page() *Page
- func (d *Document) PageCount() int
- func (d *Document) Path(dpath string) *Document
- func (d *Document) QuadraticCurveTo(x1, y1, x, y float64) *Document
- func (d *Document) RadialGradient(x1, y1, r1, x2, y2, r2 float64, stops []GradientStop) string
- func (d *Document) Rect(x, y, w, h float64) *Document
- func (d *Document) RegisterFont(family string, data []byte, index int) error
- func (d *Document) RegisterFontFile(family, path string, index int) error
- func (d *Document) RegisterImage(name string, data []byte) (string, error)
- func (d *Document) RegisterImageFile(name, path string) (string, error)
- func (d *Document) RestoreGraphics() *Document
- func (d *Document) Rotate(angleDeg float64) *Document
- func (d *Document) RoundedRect(x, y, w, h, r float64) *Document
- func (d *Document) Save(w io.Writer) error
- func (d *Document) SaveGraphics() *Document
- func (d *Document) Scale(sx, sy float64) *Document
- func (d *Document) Stroke() *Document
- func (d *Document) StrokeColor(c Color) *Document
- func (d *Document) SwitchToPage(i int) *Page
- func (d *Document) Text(s string, opts ...TextOptions) *Document
- func (d *Document) TextXY(x, y float64) *Document
- func (d *Document) Transform(a, b, c, e, f, g float64) *Document
- func (d *Document) Translate(x, y float64) *Document
- func (d *Document) Undash() *Document
- func (d *Document) WriteFile(path string) error
- type GradientStop
- type Info
- type Option
- type Page
- type PageSize
- type TextOptions
Constants ¶
This section is empty.
Variables ¶
var ( A4 = PageSize{595.28, 841.89} Letter = PageSize{612, 792} Legal = PageSize{612, 1008} A3 = PageSize{841.89, 1190.55} )
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is a PDF being created or modified.
func Open ¶
Open reads an existing PDF for modification / page copying. Non-seekable readers are spooled to a temp file. Objects are loaded lazily from the file until pages are materialized (Merge or Save).
func OpenFile ¶
OpenFile opens a PDF from disk without copying it into memory up front. The file remains open until Document.Close or after pages are materialized and the source is released.
func (*Document) Close ¶ added in v0.5.0
Close releases any file/temp resources held by an opened PDF. After Close, Save still works if pages were already materialized (e.g. after Merge); otherwise Open'd pages must be saved before Close, or Save will materialize first while the source is open.
func (*Document) FillAndStroke ¶
func (*Document) FillEvenOdd ¶
func (*Document) FillShading ¶
func (*Document) Font ¶
Font selects a standard font by name or previously registered embedded font family.
func (*Document) HasLiveImportSource ¶ added in v0.5.0
HasLiveImportSource reports whether any page still references an open source model. Intended for tests and diagnostics.
func (*Document) Image ¶
Image draws a registered image at x,y with width w (height scaled if h<=0).
func (*Document) LinearGradient ¶
func (d *Document) LinearGradient(x1, y1, x2, y2 float64, stops []GradientStop) string
LinearGradient creates an axial shading. Returns a shading name for FillShading.
func (*Document) List ¶
func (d *Document) List(items []string, opts ...TextOptions) *Document
List draws a bulleted list.
func (*Document) Merge ¶
Merge appends all pages from other into d. Imported pages are materialized into d (cloned into d.importCat) so other can be Closed and its source file released without keeping all merge inputs in memory.
func (*Document) MergeFiles ¶
MergeFiles opens and merges PDF files into d one at a time, releasing each source after its pages are materialized into d.
func (*Document) QuadraticCurveTo ¶
func (*Document) RadialGradient ¶
func (d *Document) RadialGradient(x1, y1, r1, x2, y2, r2 float64, stops []GradientStop) string
RadialGradient creates a radial shading.
func (*Document) RegisterFont ¶
RegisterFont loads a TTF/OTF/WOFF/WOFF2/TTC font from bytes. index selects a face in a collection (usually 0).
func (*Document) RegisterFontFile ¶
RegisterFontFile loads a font from disk.
func (*Document) RegisterImage ¶
RegisterImage loads JPEG or PNG from bytes and returns a resource name.
func (*Document) RegisterImageFile ¶
RegisterImageFile loads an image from disk.
func (*Document) RestoreGraphics ¶
func (*Document) RoundedRect ¶
RoundedRect appends a rectangle with corner radius r (clamped to half sides).
func (*Document) SaveGraphics ¶
func (*Document) StrokeColor ¶
func (*Document) SwitchToPage ¶
SwitchToPage selects a page by 0-based index and makes it current for subsequent draws.
type GradientStop ¶
GradientStop is a color stop for gradients (Offset in 0..1).
type Info ¶
type Info struct {
Title, Author, Subject, Keywords, Creator, Producer string
}
Info holds document metadata.
type Option ¶
type Option func(*Document)
Option configures a Document.