p4p

package module
v0.0.0-...-f35b4cb Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

README

lib-p4p

Simply create a PDF file from image(s). Backend library for pic4pdf.

Go Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(pageSize PageSize, unit Unit, imgWidthPx, imgHeightPx int, opts ImageOptions) (x, y, w, h float64, cropX1, cropY1, cropX2, cropY2 int, crop bool)

Returns an the image layout if rendered onto a the specified page in specified units. Cropping coordinates are in pixels on the image. Cropping is only necessary if crop returns true.

Types

type Generator

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

func NewGenerator

func NewGenerator(pageSize PageSize) *Generator

func (*Generator) AddImage

func (g *Generator) AddImage(img image.Image, opts ImageOptions) error

func (*Generator) AddImageFile

func (g *Generator) AddImageFile(path string, opts ImageOptions) error

func (*Generator) Write

func (g *Generator) Write(w io.Writer) error

func (*Generator) WriteFile

func (g *Generator) WriteFile(path string) error

type ImageOptions

type ImageOptions struct {
	Mode Mode
	// Scale the image's size before positioning; works with all layouts (default: 1).
	Scale float64
}

type Mode

type Mode int
const (
	// Center image on page; default DPI: 72.
	Center Mode = iota
	// Scale image to the maximum size where it remains entirely visible.
	Fit
	// Scale image to the size where it takes up the whole page; will chop off edge parts of the image.
	Fill
)

type PageSize

type PageSize struct {
	W    float64
	H    float64
	Unit Unit
}

func A1

func A1() PageSize

func A2

func A2() PageSize

func A3

func A3() PageSize

func A4

func A4() PageSize

func A5

func A5() PageSize

func A6

func A6() PageSize
func Legal() PageSize

func Letter

func Letter() PageSize

func Tabloid

func Tabloid() PageSize

func (PageSize) Convert

func (s PageSize) Convert(to Unit) PageSize

Converts the given page size into the same page size represented by a different unit

func (PageSize) Rotate

func (s PageSize) Rotate() PageSize

Rotates the page size by 90 degrees (switching to landscape on default page sizes).

type Unit

type Unit float64

Base unit is Pt.

const (
	Point      Unit = 1
	Millimeter Unit = Centimeter / 10
	Centimeter Unit = Inch / 2.54
	Inch       Unit = 72
)

Jump to

Keyboard shortcuts

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