fpdf

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: BSD-3-Clause Imports: 7 Imported by: 2

README

go-fpdf

An opionated Go package for working with the jung-kurt/gofpdf package.

Documentation

Documentation is incomplete at this time.

Motivation

Most of this code is derived from the aaronland/go-picturebook package and is concerned with the details of creating a new jung-kurt/gofpdf.Fpdf document and assigning margins, borders, bleeds and fonts. It does implement or abstract away any of the jung-kurt/gofpdf.Fpdf functionality which is expected to be handled on a per-use basis accessing a public gofpdf.Fpdf instance.

The jung-kurt/gofpdf.Fpdf package stopped being updated a while ago. Since then the package has beeen forked and appears to be actively maintained by the go-pdf/fpdf project. Eventually this package will probably be updated to use that.

See also

Documentation

Overview

Package pdpf is an opionated package around the jung-kurt/gofpdf package.

Index

Constants

View Source
const MM2INCH float64 = 25.4

MM2INCH defines the number if millimeters in an inch.

Variables

This section is empty.

Functions

func AppendFlags

func AppendFlags(fs *flag.FlagSet) error

Types

type Borders

type Borders struct {
	// The size of any border to add to the top of each image.
	Top float64
	// The size of any border to add to the bottom of each image.
	Bottom float64
	// The size of any border to add to the left-hand side of each image.
	Left float64
	// The size of any border to add to the right-hand side of each image.
	Right float64
}

type Borders defines a struct for storing borders to be applied to a images in a PDF document.

type Canvas

type Canvas struct {
	// The width of the internal canvas.
	Width float64
	// The height of the internal canvas.
	Height float64
}

type Canvas defines a struct for storing canvas information for a PDF document.

type Document

type Document struct {
	// A `gofpdf.Fpdf` instance used to produce the picturebook PDF file.
	PDF *gofpdf.Fpdf
	// A `sync.Mutex` instance used to add images in an orderly fashion.
	Mutex *sync.Mutex
	// The `PictureBookBorders` definition to use for this picturebook
	Borders *Borders
	// The `PictureBookMargins` definition to use for this picturebook
	Margins *Margins
	// The `PictureBookCanvas` definition to use for this picturebook
	Canvas Canvas
	// The `PictureBookText` definition to use for this picturebook
	Text Text
	// The `PictureBookOptions` used to create this picturebook
	Options *Options
	// contains filtered or unexported fields
}

type Document provides a struct for creating a PDF file from a folder of images (a picturebook).

func NewDocument

func NewDocument(ctx context.Context, opts *Options) (*Document, error)

New returns a new “ instances configured according to the settings in 'opts'.

func (*Document) Save

func (d *Document) Save(path string) error

type Margins

type Margins struct {
	// The size of any margin to add to the top of each page.
	Top float64
	// The size of any margin to add to the bottom of each page.
	Bottom float64
	// The size of any margin to add to the left-hand side of each page.
	Left float64
	// The size of any margin to add to the right-hand side of each page.
	Right float64
}

type Margins defines a struct for storing margins to be applied to a PDF document.

type Options

type Options struct {
	// The orientation of the final . Valid options are "P" and "L" for portrait and landscape respectively.
	Orientation string
	// A string label corresponding to known size. Valid options are "a1", "a2", "a3", "a4", "a5", "a6", "a7", "letter", "legal" and "tabloid".
	Size string
	// The width of the final document.
	Width float64
	// The height of the final document.
	Height float64
	// The unit of measurement to use for the `Width` and `Height` options.
	Units string
	// The number dots per inch to use when calculating the size of the final . Valid options are "inches", "centimeters", "millimeters".
	DPI float64
	// The size of any border to apply to each image in the final document.
	Border float64
	// The size of any additional bleed to apply to the final document.
	Bleed float64
	// The size of any margin to add to the top of each page.
	MarginTop float64
	// The size of any margin to add to the bottom of each page.
	MarginBottom float64
	// The size of any margin to add to the left-hand side of each page.
	MarginLeft float64
	// The size of any margin to add to the right-hand side of each page.
	MarginRight float64
	// A boolean value to enable to use of an OCRA font for writing captions.
	OCRAFont bool
}

Options defines a struct containing configuration information for a given PDF document.

func DefaultOptions

func DefaultOptions(ctx context.Context) (*Options, error)

NewDefaultOptions returns an `Options` instance with default settings.

func OptionsFromFlagSet added in v0.0.2

func OptionsFromFlagSet(ctx context.Context, fs *flag.FlagSet) (*Options, error)

OptionsFromFlagSet returns an `Options` instance with properties derived from 'fs'.

type Text

type Text struct {
	// The name of the font to use for text strings.
	Font string
	// The style of the font to use for text strings.
	Style string
	// The size of the font to use for text strings.
	Size float64
	// The margin to apply to text strings.
	Margin float64
	// The colour of the font to use for text strings.
	Colour []int
}

type Text defines a struct for storing information for how text should be displayed in a .

Jump to

Keyboard shortcuts

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