lazypdf

package module
v2.0.0-...-6465982 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

README

LazyPDF

This is a rasterizing engine for PDF documents built around MuPDF and jemalloc. Works on Linux and macOS.

Using

Run the command go get github.com/nitro/lazypdf/v2 to add the dependency to your project. The documentation can be found here.

Building

go build

Testing

go test -race

Updating the native libraries

To update MuPDF or jemalloc simply change its version at misc/{library}/version and submit the change at a pull request. GitHub Actions will then trigger the process of updating the library and headers through a series of commits at the pull request branch.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PageCount

func PageCount(ctx context.Context, rawPayload io.Reader) (_ int, err error)

PageCount is used to return the page count of the document.

func SaveToPNG

func SaveToPNG(ctx context.Context, page, width uint16, scale float32, rawPayload io.Reader, output io.Writer) (err error)

SaveToPNG is used to convert a page from a PDF file to PNG. Internally everything is based on the scale factor and this value is used to determine the actual output size based on the original size of the page. If none is set we'll use a default scale factor of 1.5. When using the default value, 1.5, there is a special case when we detect that the page is a landscape and it has a 0 or 180 degree rotation, on those cases we set the scale factor as 1. If width is set then we'll calculate the scale factor by dividing the width by the page horizontal size. If both width and scale are set we'll use only the scale as it takes precedence.

Types

This section is empty.

Jump to

Keyboard shortcuts

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