Documentation
¶
Index ¶
- Constants
- func EncodeImageAsXObject(img image.Image, quality int) ([]byte, error)
- func EncodeJPEGAsXObject(jpegBytes []byte, width, height int) ([]byte, error)
- func ReadImage(r io.Reader) (image.Image, string, error)
- type Page
- func (p *Page) DrawLine(x1, y1, x2, y2, lineWidth, r, g, b float64)
- func (p *Page) DrawRect(x, y, w, h, r, g, b float64)
- func (p *Page) DrawText(x, y float64, text string)
- func (p *Page) PlaceImage(name string, x, y, w, h float64)
- func (p *Page) SetFillColor(r, g, b float64)
- func (p *Page) SetFont(name string, size float64)
- type Writer
Constants ¶
const ( A4Width = 595.28 A4Height = 841.89 LetterWidth = 612.0 LetterHeight = 792.0 )
Standard PDF page sizes in points (1 point = 1/72 inch)
Variables ¶
This section is empty.
Functions ¶
func EncodeImageAsXObject ¶
EncodeImageAsXObject encodes an image.Image as a PDF image XObject dictionary+stream. Returns the raw object content ready to be embedded via w.set(). For JPEG source bytes, use EncodeJPEGAsXObject instead to avoid re-encoding.
func EncodeJPEGAsXObject ¶
EncodeJPEGAsXObject wraps already-encoded JPEG bytes as a PDF image XObject.
Types ¶
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page accumulates the content stream for a single PDF page. All coordinates are in PDF user space: origin at bottom-left, Y increases upwards Callers work in top-left document space and convert via Page.toY()
func (*Page) DrawRect ¶
DrawRect draws a filled rectangle in top-left document coordinates. (x, y) is the top-left corner.
func (*Page) DrawText ¶
DrawText renders a UTF-8 strings at doc-space (x, y). y is the baseline position in top-left document coordinates.
func (*Page) PlaceImage ¶
PlaceImage renders a named XObject (image) at doc-space position. width and height are the rendered dimensions in points.
func (*Page) SetFillColor ¶
SetFillColor sets the fill color using normalized RGB (0.0-1.0)
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer constructs a PDF 1.4 document Usage:
w := NewWriter() pg := w.AddPage(A4Width, A4Height) pg.SetFont("F1", 12) pg.DrawText(72, 72, "Hello, PDF") pdf, err := w.Write()