Creating Documents
Creating a document from scratch means the creator package. creator.New() returns a
Creator, every component is made from it, c.Draw puts a component into the document, and
c.WriteToFile produces the PDF. Reports, invoices, tables, images and barcodes are all
components drawn into that one flow.
Drawn content stacks down the page in the order you draw it and continues onto a new page
when it runs out of room. SetPos(x, y) takes a component out of that flow and pins it
somewhere instead. Those coordinates start at the top left of the page and y grows
downward, which is upside down compared to PDF’s own user space;
how PDF coordinate systems work has the conversion.
Two components lay content out in cells. Table takes a column count and fills cells in
order, starting a new row once the current one is full. Grid makes rows explicit objects
you ask for cells from. Grid arrived in v4 as the more predictable of the two and is
usually the better starting point for new code, though header rows repeated on every page
still only exist on Table.
- How PDF coordinate systems work with UniPDF
- How to create a PDF report in landscape mode
- How to create PDF reports in Golang
- How to generate a table inside a PDF
- How to generate PDF invoices in Golang
- How to insert a barcode into a PDF
- How to insert an image into a PDF
- How to reduce the size of generated PDF reports
- How to use CJK font to render text
- Using color in PDF documents