Documentation ¶
Overview ¶
Package scpdf is an ultra-simple PDF generation library for all Snowman Comedians.
To achieve the simplicity, the content of the PDF document is limited to essential stuffs, that is, snowman pictures. You can choose the color of the mufflers that the snowmen wear.
doc := scpdf.Doc{} file, err := os.Create("essential.pdf") if err != nil { /* blah */ } n, err := doc.WriteTo(file) if err != nil { /* blah */ } file.Close()
Index ¶
- func FormatDate(t time.Time) string
- func Version() string
- type Doc
- func (d *Doc) AddPage(muffler color.Color) error
- func (d *Doc) AddPageScaled(muffler color.Color, scale float64) error
- func (d *Doc) Bytes() (bs []byte, err error)
- func (d *Doc) PageSize() (float64, float64)
- func (d *Doc) PdfBytes() (bs []byte, err error)
- func (d *Doc) SetDocInfo(info map[string]string) (err error)
- func (d *Doc) SetPageSize(width, height float64) error
- func (d *Doc) String() string
- func (d *Doc) WriteTo(wr io.Writer) (n int64, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatDate ¶
FormatDate stringifies a time.Time value in the form suitable for PDF creation date information.
Types ¶
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc represents an SC-oriented PDF document.
func NewWithSize ¶
NewWithSize makes a new document with the given width and height (measured in PDF points).
func (*Doc) AddPage ¶
AddPageScaled adds to this document a new page with the given muffler color (without scale).
func (*Doc) AddPageScaled ¶
AddPageScaled adds to this document a new page with the given muffler color and the scale value to the standard snowman size.
func (*Doc) PdfBytes ¶
PdfBytes generates the PDF file content and returns the resulted bytes. The same notice on WriteTo also applies.
func (*Doc) SetDocInfo ¶
SetDocInfo specifies several kinds of information of this document. The input is given as a map of strings.
The following keys are effective:
version: PDF version, such as "1.5" (default: "1.4") title / author / subject: with obvious meanings (default: empty) creator: name of the PDF generation software (default: "scpdf") creationDate: in the form "D:20180808120000+09'00'" (default: now)
func (*Doc) SetPageSize ¶
SetPageSize sets the width and the height (measured in PDF points) of this document. The length values must be positive.
func (*Doc) WriteTo ¶
WriteTo generates the PDF file content of this document and writes the resulted bytes to an io.Writer. Since a PDF file with no pages is disallowed, the "default page" (a snowman with red muffler) will be added if the document has no pages yet.
After generation, the document is frozen; no further modification to the document is allowed.