scpdf

package module
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2018 License: MIT Imports: 11 Imported by: 1

README

scpdf

Go: An ultra-simple PDF generation library for Snowman Comedians

doc := scpdf.Doc{}
file, err := os.Create("essential.pdf")
if err != nil { /* blah */ }
n, err := doc.WriteTo(file)
if err != nil { /* blah */ }
file.Close()

API

See GoDoc.

LICENSE

MIT License

CHANGELOG

  • Version 0.18.0 <2018/11/30>
    • Added (*Doc).Bytes().
    • Added Version().
  • Version 0.8.2 <2018/11/02>
  • Version 0.8.1 <2018/07/15>
  • Version 0.8.0 <2018/02/27>
    • Beta release.

Takayuki YATO (aka. "ZR")
https://github.com/zr-tex8r

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDate

func FormatDate(t time.Time) string

FormatDate stringifies a time.Time value in the form suitable for PDF creation date information.

func Version added in v0.18.0

func Version() string

Version returns the version of this package.

Types

type Doc

type Doc struct {
	// contains filtered or unexported fields
}

Doc represents an SC-oriented PDF document.

func NewWithSize

func NewWithSize(width, height float64) (*Doc, error)

NewWithSize makes a new document with the given width and height (measured in PDF points).

func (*Doc) AddPage

func (d *Doc) AddPage(muffler color.Color) error

AddPageScaled adds to this document a new page with the given muffler color (without scale).

func (*Doc) AddPageScaled

func (d *Doc) AddPageScaled(muffler color.Color, scale float64) error

AddPageScaled adds to this document a new page with the given muffler color and the scale value to the standard snowman size.

func (*Doc) Bytes added in v0.18.0

func (d *Doc) Bytes() (bs []byte, err error)

Bytes is an alias to PdfBytes, provided to satisfy scdoc.Doc.

func (*Doc) PageSize

func (d *Doc) PageSize() (float64, float64)

PageSize returns the width and height of this document.

func (*Doc) PdfBytes

func (d *Doc) PdfBytes() (bs []byte, err error)

PdfBytes generates the PDF file content and returns the resulted bytes. The same notice on WriteTo also applies.

func (*Doc) SetDocInfo

func (d *Doc) SetDocInfo(info map[string]string) (err error)

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

func (d *Doc) SetPageSize(width, height float64) error

SetPageSize sets the width and the height (measured in PDF points) of this document. The length values must be positive.

func (*Doc) String

func (d *Doc) String() string

String dumps the internal information of the Doc value.

func (*Doc) WriteTo

func (d *Doc) WriteTo(wr io.Writer) (n int64, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL