paper

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 23 Imported by: 3 modules, 38 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Paper

pkg.go.dev Go Report Card License

Paper is a Go library for creating PDF documents from HTML and structured components.

Use it when you want a direct HTML-to-PDF path, or when you need programmatic layout with rows, columns, headers, footers, metrics, tests, and explicit control over document generation.

Paper logo

Installation

go get github.com/avdoseferovic/paper

The structure assertion helper ships with the root module and adds no third-party dependencies — import github.com/avdoseferovic/paper/pkg/test directly.

HTML to PDF

For HTML-only documents, use paper.FromHTML.

package main

import (
	"context"
	"log"

	"github.com/avdoseferovic/paper"
)

func main() {
	doc, err := paper.FromHTML(context.Background(), `<h1>Hello</h1><p>World</p>`)
	if err != nil {
		log.Fatal(err)
	}

	if err := doc.Save("out.pdf"); err != nil {
		log.Fatal(err)
	}
}

All generation entry points take a context.Context as their first argument, so long-running conversions can be canceled or given deadlines.

Use paper.FromHTMLReader when the source HTML is already available as an io.Reader. For advanced HTML options such as asset base directories, call pkg/html directly and add the returned rows to a paper.New(...) document.

For mixed layouts, HTML fragments can also be used as regular components via github.com/avdoseferovic/paper/pkg/components/html:

htmlBlock, err := htmlcomponent.New(context.Background(), `<h2>Terms</h2><p>Rendered from HTML.</p>`)
if err != nil {
	log.Fatal(err)
}

doc := paper.New()
doc.AddAutoRow(
	col.New(6).Add(text.New("Direct Paper component")),
	col.New(6).Add(htmlBlock),
)

Component Layout

Use the row and column API when a document needs manual layout, repeated headers or footers, generated pages, metrics, or a testable component tree.

package main

import (
	"context"
	"log"

	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/components/col"
	htmlcomponent "github.com/avdoseferovic/paper/pkg/components/html"
	"github.com/avdoseferovic/paper/pkg/components/row"
	"github.com/avdoseferovic/paper/pkg/components/text"
	"github.com/avdoseferovic/paper/pkg/config"
	"github.com/avdoseferovic/paper/pkg/props"
)

func main() {
	cfg := config.NewBuilder().
		WithLeftMargin(15).
		WithTopMargin(15).
		Build()

	doc := paper.New(cfg)
	htmlBlock, err := htmlcomponent.New(context.Background(), `<p>HTML fragment inside the grid</p>`)
	if err != nil {
		log.Fatal(err)
	}

	doc.AddRows(
		row.New(12).Add(
			col.New(12).Add(text.New("Invoice", props.Text{Size: 18})),
		),
		row.New().Add(
			col.New(6).Add(text.New("Programmatic content")),
			col.New(6).Add(htmlBlock),
		),
		text.NewRow(8, "Generated with Paper"),
	)

	pdf, err := doc.Generate(context.Background())
	if err != nil {
		log.Fatal(err)
	}

	if err := pdf.Save("invoice.pdf"); err != nil {
		log.Fatal(err)
	}
}

Paper uses a grid-based layout model. Rows stack vertically, columns split a row across the configured grid width (12 columns by default, configurable with WithMaxGridSize), and new pages are added automatically when content exceeds the useful page area after margins, headers, and footers are reserved.

Key Features

  • HTML-to-PDF conversion through paper.FromHTML, paper.FromHTMLReader, and pkg/html — including @page size/margins and repeating top-level <header>/<footer> bands.
  • Programmatic PDF layout with rows, columns, text, images, codes, tables, signatures, page numbers, headers, and footers.
  • PDF outline bookmarks via props.Outline (and auto-generated from HTML headings with WithOutlineFromHeadings), preserved in every generation mode.
  • Per-page text watermarks via config.WithWatermark.
  • Document output as bytes, base64, saved files, or merged PDFs (see Merging PDFs for limitations).
  • PDF permission protection for casual copy/print deterrence, not confidentiality-grade encryption. RC4 is the compatibility default; AES-128 is available with WithProtectionAlgorithm.
  • Component-tree inspection through GetStructure, designed for deterministic unit tests.
  • Optional generation metrics through decorator.NewMetrics.
  • Internal PDF backend ownership, so application code depends on Paper's public packages rather than a third-party renderer API.

Browser / WebAssembly

Paper is pure Go and compiles to WebAssembly, so PDF generation can run entirely in the browser — no server round-trip. The Paper Playground (examples/cmd/wasm) is a live editor with an HTML mode and a component-grid (JSON) mode; the preview shows the real generated PDF as you type. Try it live: https://avdoseferovic.github.io/paper/playground/ (also linked from the project site, deployed via GitHub Pages). To run it locally, build with make wasm and serve the web/ directory. The syscall/js bindings expose two globals — paperGeneratePDF(html) and paperGenerateFromSpec(json, pageSize) — each returning { pdf: "<base64>" } or { error: "<message>" }.

See docs/wasm-support.md for the JS API contract, the component-grid JSON schema, build/serve steps, and browser limitations (no filesystem: use data: URIs and AddUTF8FontFromBytes; Save is unavailable — use GetBase64/GetBytes).

Merging PDFs

merge.Bytes (package pkg/merge) concatenates the pages of multiple PDFs into one document. It is designed for PDFs produced by Paper itself and has two hard limitations for external input:

  • Encrypted PDFs are not supported. Password-protected input returns an error; decrypt before merging.
  • Cross-reference streams are not supported. Many modern tools emit PDFs with xref streams (PDF 1.5+ compressed object streams); those inputs are rejected. Re-save such files with a classic xref table first.

Performance

Generation is benchmarked in benchmark_test.go. Two benchmarks live there:

  • BenchmarkPDFGeneration — representative documents (text-heavy, mixed components, HTML translation, full HTML demo).
  • BenchmarkPDFScaling — a text document swept across 10–1000 rows to expose the per-row / per-page cost curve.

Run them with:

# Representative scenarios
go test -run='^$' -bench=BenchmarkPDFGeneration -benchmem -count=6 .

# Size scaling curve
go test -run='^$' -bench=BenchmarkPDFScaling -benchmem -count=6 .

The numbers below are the median of 6 checked runs on an Apple M1 Pro (Go 1.26.4), single-threaded. They are representative of the bundled fixtures, not a universal guarantee — actual time scales with page count, image size, and component mix.

Representative documents (BenchmarkPDFGeneration)
Scenario Document Time / doc Mem / doc Allocs / doc
TextHeavy 180 text rows (~6 pages) 1.13 ms 1.31 MiB 9,501
HTMLDemoTranslateOnly HTML → component rows without PDF generation 1.43 ms 2.00 MiB 12,807
MixedComponents 40× (barcode + QR + image + signature + text) 5.11 ms 3.66 MiB 12,799
HTMLDemoFull HTML → PDF: header + styled body + embedded PNG 6.01 ms 9.72 MiB 38,271
Size scaling (BenchmarkPDFScaling)
Rows ~Pages (A4) Time / doc Mem / doc Allocs / doc
10 1 0.32 ms 165 KiB 2,276
50 2 0.51 ms 435 KiB 3,963
100 4 0.75 ms 768 KiB 6,096
500 17 2.77 ms 3.21 MiB 23,084
1000 34 5.24 ms 6.32 MiB 44,265

The curve is linear, giving a simple cost model for text content:

time(N rows) ≈ 0.27 ms (fixed setup) + 5.0 µs × N

That is roughly ~145 µs per A4 page and ~42 allocations per row. Generation is single-threaded and the internal compression writers are pooled in a concurrency-safe way, so throughput scales ~linearly across cores when generating documents in parallel.

Documentation

Development

Command Description
make build Build the project
make test Run unit tests
make fmt Format Go files
make lint Run lint checks
make dod Run the local definition-of-done checks
make examples Run documentation examples
make docs Start the local docs server

Contributor onboarding — toolchain setup, the multi-module workspace layout, golden-file tests, and mock generation — is covered in DEVELOPMENT.md.

Credits

Paper is derived from and inspired by Maroto, created by Johnathan Fercher da Rosa and contributors. The original project established the Bootstrap-style row and column PDF authoring model that Paper continues to evolve.

Logo art credit remains with @marinabankr.

License

Paper is released under the MIT License.

Documentation

Overview

Package paper builds PDF documents from a grid of rows and columns.

A document is assembled by adding rows to a Paper instance and then calling Generate. Components such as text, images, barcodes, and signatures are placed into columns, which share a fixed number of grid units per row. HTML input is supported through FromHTML and its variants.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotGenerateInLowMemoryMode       = errors.New("an error has occurred while trying to generate PDFs in low memory mode")
	ErrCannotGenerateInParallelMode        = errors.New("an error has occurred while trying to generate PDFs concurrently")
	ErrFooterHeightIsGreaterThanUsefulArea = errors.New("footer height is greater than page useful area")
	ErrHeaderHeightIsGreaterThanUsefulArea = errors.New("header height is greater than page useful area")
	// ErrHTMLHeaderAfterContent is returned by AddHTML when the HTML contains
	// a top-level <header>/<footer> but the document already has rows or a
	// registered header/footer: late registration would not reserve space on
	// already-built pages.
	ErrHTMLHeaderAfterContent = errors.New("html top-level header/footer must be added before any other content")
)

Errors reported while generating a document.

Functions

func FromHTML

func FromHTML(ctx context.Context, htmlStr string, cfgs ...*entity.Config) (*core.Pdf, error)

FromHTML converts an HTML string directly into a PDF document. It is the shortest path for callers that only need HTML-to-PDF output. It observes ctx while parsing/translating HTML and while generating the PDF. Optional configs are the same configs accepted by New.

When no config argument is given, a plain `@page { size; margin }` rule in the HTML configures the page; an explicit config argument disables @page handling entirely (documented precedence rule, no field-level merging).

Example

ExampleFromHTML demonstrates the shortest path from HTML to PDF.

package main

import (
	"context"
	"log"

	"github.com/avdoseferovic/paper"
)

func main() {
	doc, err := paper.FromHTML(context.Background(), `<h1>Hello</h1><p>World</p>`)
	if err != nil {
		log.Fatal(err)
	}

	_ = doc.GetBytes()

}

func FromHTMLReader

func FromHTMLReader(ctx context.Context, r io.Reader, cfgs ...*entity.Config) (*core.Pdf, error)

FromHTMLReader reads HTML from r and converts it directly into a PDF document. It observes ctx before and after reading, while translating HTML, and while generating the PDF. Optional configs are the same configs accepted by New.

func FromHTMLWithOptions added in v0.2.2

func FromHTMLWithOptions(ctx context.Context, htmlStr string, opts []html.Option, cfgs ...*entity.Config) (*core.Pdf, error)

FromHTMLWithOptions is FromHTML with additional html conversion options (e.g. html.WithImageBaseDir, html.WithStrictAssets) appended to the config-derived defaults.

Types

type Paper

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

Paper builds a document. Add rows to it, then call Generate to produce the PDF.

func New

func New(cfgs ...*entity.Config) *Paper

New creates a concrete Paper instance. It's optional to provide an *entity.Config with customizations those customization are created by using the config.Builder.

Example

ExampleNew demonstrates how to create a paper instance.

package main

import (
	"context"

	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/config"
)

func main() {
	// optional
	b := config.NewBuilder()
	cfg := b.Build()

	m := paper.New(cfg) // cfg is an optional

	// Do things and generate
	_, _ = m.Generate(context.Background())

}

func NewPaper

func NewPaper(cfgs ...*entity.Config) *Paper

NewPaper creates a concrete Paper instance.

func (*Paper) AddAnnotation added in v0.2.2

func (m *Paper) AddAnnotation(annotation entity.PageAnnotation)

AddAnnotation adds a page annotation to the generated PDF.

func (*Paper) AddAttachment added in v0.2.2

func (m *Paper) AddAttachment(attachment entity.FileAttachment)

AddAttachment embeds a file in the generated PDF.

func (*Paper) AddAutoRow

func (m *Paper) AddAutoRow(cols ...core.Col) core.Row

AddAutoRow is responsible for adding a line with automatic height to the current document. The row height will be calculated based on its content.

func (*Paper) AddHTML

func (m *Paper) AddHTML(ctx context.Context, htmlStr string) error

AddHTML parses an HTML string into Paper rows and adds them to the current document. It observes ctx while parsing and translating the HTML. Headers, footers, and pagination continue to work as with manually constructed rows. For advanced options (e.g. html.WithImageBaseDir for safe <img> loading), call html.FromString directly and append the returned rows via m.AddRows(rows...). Supported HTML subset is documented in docs/html-support.md.

func (*Paper) AddHighlight added in v0.2.2

func (m *Paper) AddHighlight(pageIndex int, rect [4]float64, color [3]float64, quadPoints [][8]float64)

AddHighlight adds a highlight text-markup annotation.

func (*Paper) AddInternalLinkAnnotation added in v0.2.2

func (m *Paper) AddInternalLinkAnnotation(pageIndex int, rect [4]float64, destName string)

AddInternalLinkAnnotation adds an internal named-destination link annotation.

func (*Paper) AddLinkAnnotation added in v0.2.2

func (m *Paper) AddLinkAnnotation(pageIndex int, rect [4]float64, uri string)

AddLinkAnnotation adds an external URI link annotation to a generated page.

func (*Paper) AddNamedDestination added in v0.2.2

func (m *Paper) AddNamedDestination(destination entity.NamedDestination)

AddNamedDestination defines a named location in the generated PDF.

func (*Paper) AddPageLinkAnnotation added in v0.2.2

func (m *Paper) AddPageLinkAnnotation(pageIndex int, rect [4]float64, destPage int)

AddPageLinkAnnotation adds an internal link annotation to a zero-based page index.

func (*Paper) AddPages

func (m *Paper) AddPages(pages ...core.Page)

AddPages is responsible for add pages directly in the document. By adding a page directly, the current cursor will reset and the new page will appear as the next. If the page provided have more rows than the maximum useful area of a page, paper will split that page in more than one.

Example

ExamplePaper_AddPages demonstrates how to add a new page in paper.

package main

import (
	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/components/code"
	"github.com/avdoseferovic/paper/pkg/components/page"
)

func main() {
	m := paper.New()

	p := page.New()
	p.Add(code.NewBarRow(10, "barcode"))

	m.AddPages(p)

	// Do things and generate

}

func (*Paper) AddRow

func (m *Paper) AddRow(rowHeight float64, cols ...core.Col) core.Row

AddRow is responsible for add one row in the current document. By adding a row, if the row will extrapolate the useful area of a page, paper will automatically add a new page. Paper use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.

Example

ExamplePaper_AddRow demonstrates how to add a new row in paper.

package main

import (
	"github.com/avdoseferovic/paper/pkg/components/text"

	"github.com/avdoseferovic/paper"
)

func main() {
	m := paper.New()

	m.AddRow(10, text.NewCol(12, "text"))

	// Do things and generate

}

func (*Paper) AddRows

func (m *Paper) AddRows(rows ...core.Row)

AddRows is responsible for add rows in the current document. By adding a row, if the row will extrapolate the useful area of a page, paper will automatically add a new page. Paper use the information of PageSize, PageMargin, FooterSize and HeaderSize to calculate the useful area of a page.

Example

ExamplePaper_AddRows demonstrates how to add new rows in paper.

package main

import (
	"github.com/avdoseferovic/paper/pkg/components/text"

	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/components/code"
)

func main() {
	m := paper.New()

	m.AddRows(
		code.NewBarRow(12, "barcode"),
		text.NewRow(12, "text"),
	)

	// Do things and generate

}

func (*Paper) AddSquiggly added in v0.2.2

func (m *Paper) AddSquiggly(pageIndex int, rect [4]float64, color [3]float64, quadPoints [][8]float64)

AddSquiggly adds a squiggly text-markup annotation.

func (*Paper) AddStrikeOut added in v0.2.2

func (m *Paper) AddStrikeOut(pageIndex int, rect [4]float64, color [3]float64, quadPoints [][8]float64)

AddStrikeOut adds a strikeout text-markup annotation.

func (*Paper) AddTextAnnotation added in v0.2.2

func (m *Paper) AddTextAnnotation(pageIndex int, rect [4]float64, text, icon string)

AddTextAnnotation adds a sticky-note annotation to a generated page.

func (*Paper) AddTextAnnotationOpen added in v0.2.2

func (m *Paper) AddTextAnnotationOpen(pageIndex int, rect [4]float64, text, icon string)

AddTextAnnotationOpen adds an initially open sticky-note annotation.

func (*Paper) AddTextMarkup added in v0.2.2

func (m *Paper) AddTextMarkup(
	pageIndex int,
	markupType entity.MarkupType,
	rect [4]float64,
	color [3]float64,
	quadPoints [][8]float64,
)

AddTextMarkup adds a text-markup annotation to a generated page.

func (*Paper) AddUnderline added in v0.2.2

func (m *Paper) AddUnderline(pageIndex int, rect [4]float64, color [3]float64, quadPoints [][8]float64)

AddUnderline adds an underline text-markup annotation.

func (*Paper) FitInCurrentPage

func (m *Paper) FitInCurrentPage(heightNewLine float64) bool

FitInCurrentPage reports whether a row of the given height fits in the remaining useful area of the current page.

Example

ExamplePaper_FitInCurrentPage demonstrates how to check if the new line fits on the current page.

package main

import (
	"github.com/avdoseferovic/paper"
)

func main() {
	m := paper.New()

	m.FitInCurrentPage(12)

	// Do things and generate

}

func (*Paper) Generate

func (m *Paper) Generate(ctx context.Context) (*core.Pdf, error)

Generate is responsible to compute the component tree created by the usage of all other Paper methods, and generate the PDF document. It observes ctx between pages and generation phases.

Example

ExamplePaper_Generate demonstrates how to generate a file.

package main

import (
	"context"
	"log"

	"github.com/avdoseferovic/paper"
)

func main() {
	m := paper.New()

	// Add rows, pages and etc.

	doc, err := m.Generate(context.Background())
	if err != nil {
		log.Fatal(err)
	}

	// You can retrieve as Base64, Save file, Merge with another file or GetReport.
	_ = doc.GetBytes()

}

func (*Paper) GetCurrentConfig

func (m *Paper) GetCurrentConfig() *entity.Config

GetCurrentConfig is responsible for returning the current settings from the file

Example

ExamplePaper_GetCurrentConfig demonstrates how to get the current paper configuration.

package main

import (
	"github.com/avdoseferovic/paper"
)

func main() {
	m := paper.New()

	m.GetCurrentConfig()

	// Do things and generate

}

func (*Paper) GetStructure

func (m *Paper) GetStructure() *node.Node[core.Structure]

GetStructure is responsible for return the component tree, this is useful on unit tests cases.

Example

ExamplePaperGetStruct demonstrates how to get paper component tree

package main

import (
	"github.com/avdoseferovic/paper/pkg/components/text"

	"github.com/avdoseferovic/paper"
)

func main() {
	m := paper.New()

	m.AddRow(40, text.NewCol(12, "text"))

	m.GetStructure()

	// Do things and generate

}

func (*Paper) RegisterFooter

func (m *Paper) RegisterFooter(rows ...core.Row) error

RegisterFooter is responsible to define a set of rows as a footer of the document. The footer will appear in every new page of the document. The footer cannot occupy an area greater than the useful area of the page, it this case the method will return an error.

Example

ExamplePaper_RegisterFooter demonstrates how to register a footer to me added in every new page. An error is returned if the area occupied by the footer is greater than the page area.

package main

import (
	"github.com/avdoseferovic/paper/pkg/components/text"

	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/components/code"
)

func main() {
	m := paper.New()

	err := m.RegisterFooter(
		code.NewBarRow(12, "barcode"),
		text.NewRow(12, "text"))
	if err != nil {
		panic(err)
	}

	// Do things and generate

}

func (*Paper) RegisterHeader

func (m *Paper) RegisterHeader(rows ...core.Row) error

RegisterHeader is responsible to define a set of rows as a header of the document. The header will appear in every new page of the document. The header cannot occupy an area greater than the useful area of the page, it this case the method will return an error.

Example

ExamplePaper_RegisterHeader demonstrates how to register a header to me added in every new page. An error is returned if the area occupied by the header is greater than the page area.

package main

import (
	"github.com/avdoseferovic/paper/pkg/components/text"

	"github.com/avdoseferovic/paper"
	"github.com/avdoseferovic/paper/pkg/components/code"
)

func main() {
	m := paper.New()

	err := m.RegisterHeader(
		code.NewBarRow(12, "barcode"),
		text.NewRow(12, "text"))
	if err != nil {
		panic(err)
	}

	// Do things and generate

}

func (*Paper) SetAcroForm added in v0.2.2

func (m *Paper) SetAcroForm(form *entity.AcroForm)

SetAcroForm attaches interactive form fields to the generated PDF. The form is cloned so later mutations of the input do not leak into the document.

func (*Paper) SetArtBox added in v0.2.2

func (m *Paper) SetArtBox(pageIndex int, box [4]float64)

SetArtBox sets a generated page ArtBox.

func (*Paper) SetBleedBox added in v0.2.2

func (m *Paper) SetBleedBox(pageIndex int, box [4]float64)

SetBleedBox sets a generated page BleedBox.

func (*Paper) SetCropBox added in v0.2.2

func (m *Paper) SetCropBox(pageIndex int, box [4]float64)

SetCropBox sets a generated page CropBox.

func (*Paper) SetDeterministic added in v0.2.2

func (m *Paper) SetDeterministic(deterministic bool)

SetDeterministic makes repeated builds of the same document byte-identical.

func (*Paper) SetFileID added in v0.2.2

func (m *Paper) SetFileID(id []byte)

SetFileID sets an explicit trailer /ID for the generated PDF.

func (*Paper) SetLanguage added in v0.2.2

func (m *Paper) SetLanguage(language string)

SetLanguage sets the document language written to the catalog /Lang entry.

func (*Paper) SetPageGeometry added in v0.2.2

func (m *Paper) SetPageGeometry(geometry entity.PageGeometry)

SetPageGeometry configures generated PDF page dictionary geometry entries.

func (*Paper) SetPageLabels added in v0.2.2

func (m *Paper) SetPageLabels(labels ...entity.PageLabelRange)

SetPageLabels defines the labels viewers show instead of physical page numbers.

func (*Paper) SetPageRotation added in v0.2.2

func (m *Paper) SetPageRotation(pageIndex, degrees int)

SetPageRotation sets a generated page rotation in degrees.

func (*Paper) SetPdfA added in v0.2.2

func (m *Paper) SetPdfA(config entity.PdfAConfig)

SetPdfA configures PDF/A conformance metadata and output intent at runtime.

func (*Paper) SetTagged added in v0.2.2

func (m *Paper) SetTagged(enabled bool)

SetTagged enables or disables tagged (accessible) PDF output at runtime.

func (*Paper) SetTrimBox added in v0.2.2

func (m *Paper) SetTrimBox(pageIndex int, box [4]float64)

SetTrimBox sets a generated page TrimBox.

func (*Paper) SetViewerPreferences added in v0.2.2

func (m *Paper) SetViewerPreferences(prefs entity.ViewerPreferences)

SetViewerPreferences configures catalog viewer hints at runtime.

Directories

Path Synopsis
docs module
examples module
internal
assert
Package assert provides lightweight test assertions used by the root module.
Package assert provides lightweight test assertions used by the root module.
cache
Package cache stores image bytes that have already been read from disk, so a document that reuses the same image does not read it again.
Package cache stores image bytes that have already been read from disk, so a document that reuses the same image does not read it again.
cmd/mockfix command
Command mockfix rewrites generated mocks in internal/mocks so they import the vendored mock runtime (internal/mocktest) instead of testify.
Command mockfix rewrites generated mocks in internal/mocks so they import the vendored mock runtime (internal/mocktest) instead of testify.
code
Package code generates barcode images: linear (Code 128), QR, and Data Matrix.
Package code generates barcode images: linear (Code 128), QR, and Data Matrix.
cssparse
Package cssparse provides the small, bounded CSS rule/declaration parser shared by Paper's HTML and SVG renderers.
Package cssparse provides the small, bounded CSS rule/declaration parser shared by Paper's HTML and SVG renderers.
dependency
Package dependency holds the guard test that keeps the root module free of third-party imports.
Package dependency holds the guard test that keeps the root module free of third-party imports.
fixture
Package fixture provides pre-filled entities and props for tests, so test cases only have to state the fields they actually care about.
Package fixture provides pre-filled entities and props for tests, so test cases only have to state the fields they actually care about.
goleak
Package goleak provides a small goroutine leak check for this repository's tests.
Package goleak provides a small goroutine leak check for this repository's tests.
htmllimits
Package htmllimits holds the size limits applied when rendering HTML, such as maximum image and stylesheet sizes.
Package htmllimits holds the size limits applied when rendering HTML, such as maximum image and stylesheet sizes.
imagecodec
Package imagecodec converts images into a form the PDF writer can embed, decoding the source bytes and re-encoding them when the original format is not directly supported.
Package imagecodec converts images into a form the PDF writer can embed, decoding the source bytes and re-encoding them when the original format is not directly supported.
layout
Package layout turns column weights into whole grid units and applies cell margins.
Package layout turns column weights into whole grid units and applies cell margins.
listnum
Package listnum formats the CSS numbering systems shared by list markers (<ol>) and CSS counters (counter(), counters()).
Package listnum formats the CSS numbering systems shared by list markers (<ol>) and CSS counters (counter(), counters()).
math
Package math resizes inner dimensions to fit inside outer ones while keeping the original aspect ratio.
Package math resizes inner dimensions to fit inside outer ones while keeping the original aspect ratio.
merror
Package merror holds the default text style used to draw error messages onto a generated page.
Package merror holds the default text style used to draw error messages onto a generated page.
mocktest
Package mock provides the small mock API subset used by generated internal test mocks.
Package mock provides the small mock API subset used by generated internal test mocks.
pdf
Package pdf contains Paper's internal PDF runtime.
Package pdf contains Paper's internal PDF runtime.
pdfscan
Package pdfscan holds a minimal byte scanner for the subset of PDF syntax that paper's reader, form filler and signer need in order to walk object dictionaries in place, without building a full object model.
Package pdfscan holds a minimal byte scanner for the subset of PDF syntax that paper's reader, form filler and signer need in order to walk object dictionaries in place, without building a full object model.
pngcodec
Package pngcodec encodes PNG images with pooled encoder state.
Package pngcodec encodes PNG images with pooled encoder state.
providers
Package providers contains repository-wide provider guard tests.
Package providers contains repository-wide provider guard tests.
providers/paper
Package paper implements the drawing provider that the document builder calls into.
Package paper implements the drawing provider that the document builder calls into.
providers/paper/cellwriter
Package cellwriter draws the background and border of a single cell.
Package cellwriter draws the background and border of a single cell.
require
Package require provides fail-fast test assertions used by the root module.
Package require provides fail-fast test assertions used by the root module.
svg
Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.
Package svg provides pure-Go SVG rasterisation helpers for PDF embedding.
test
Package test compares a generated document tree against a stored JSON snapshot, and reports the first field that differs.
Package test compares a generated document tree against a stored JSON snapshot, and reports the first field that differs.
time
Package time measures how long a closure takes to run and reports it as a metrics.Time value.
Package time measures how long a closure takes to run and reports it as a metrics.Time value.
pkg
barcode
Package barcode provides named barcode constructors over Paper's component model.
Package barcode provides named barcode constructors over Paper's component model.
components/checkbox
Package checkbox implements creation of checkboxes.
Package checkbox implements creation of checkboxes.
components/code
Package code implements creation of Barcode, MatrixCode and QrCode.
Package code implements creation of Barcode, MatrixCode and QrCode.
components/col
Package col implements creation of columns.
Package col implements creation of columns.
components/html
Package html implements a component wrapper for Paper's HTML translator.
Package html implements a component wrapper for Paper's HTML translator.
components/htmllist
Package htmllist implements HTML-style bullet and numbered list components.
Package htmllist implements HTML-style bullet and numbered list components.
components/image
Package image implements creation of images from file and bytes.
Package image implements creation of images from file and bytes.
components/line
Package line implements creation of lines.
Package line implements creation of lines.
components/list
Package list implements creation of lists (old tablelist).
Package list implements creation of lists (old tablelist).
components/page
Package page implements creation of pages.
Package page implements creation of pages.
components/richtext
Package richtext implements a PDF component for paragraphs with mixed inline styling.
Package richtext implements a PDF component for paragraphs with mixed inline styling.
components/row
Package row implements creation of rows.
Package row implements creation of rows.
components/signature
Package signature implements creation of signatures.
Package signature implements creation of signatures.
components/table
Package table implements a PDF table component with colspan, rowspan, and per-cell styling.
Package table implements a PDF table component with colspan, rowspan, and per-cell styling.
components/text
Package text implements creation of texts.
Package text implements creation of texts.
config
Package config implements custom configuration builder.
Package config implements custom configuration builder.
consts
Package consts groups the small enumeration types used across Paper: alignment, orientation, line styles, break-line strategies, font families, barcode types, generation modes, and provider types.
Package consts groups the small enumeration types used across Paper: alignment, orientation, line styles, break-line strategies, font families, barcode types, generation modes, and provider types.
consts/border
Package border contains all border types.
Package border contains all border types.
consts/extension
Package extension contains all image extensions.
Package extension contains all image extensions.
consts/fontstyle
Package fontstyle contains all default font styles.
Package fontstyle contains all default font styles.
consts/pagesize
Package pagesize contains all default page sizes.
Package pagesize contains all default page sizes.
consts/protection
Package protection contains all protection types.
Package protection contains all protection types.
core
Package core contains all core interfaces and basic implementations.
Package core contains all core interfaces and basic implementations.
core/entity
Package entity contains all core entities.
Package entity contains all core entities.
decorator
Package decorator provides decorators over the core.Paper interface.
Package decorator provides decorators over the core.Paper interface.
fontrepository
Package fontrepository implements font repository.
Package fontrepository implements font repository.
forms
Package forms provides AcroForm support for generated Paper PDFs.
Package forms provides AcroForm support for generated Paper PDFs.
html
Package html converts HTML strings into Paper rows so they can be added to a Paper document.
Package html converts HTML strings into Paper rows so they can be added to a Paper document.
html/css
Package css parses CSS declarations and resolves them into a ComputedStyle that the HTML translator can read.
Package css parses CSS declarations and resolves them into a ComputedStyle that the HTML translator can read.
html/dom
Package dom provides a Paper-friendly wrapper over golang.org/x/net/html.
Package dom provides a Paper-friendly wrapper over golang.org/x/net/html.
html/translate
Package translate converts a parsed HTML DOM into a slice of Paper rows.
Package translate converts a parsed HTML DOM into a slice of Paper rows.
image
Package image provides standalone image decoding helpers that can be adapted into Paper image components.
Package image provides standalone image decoding helpers that can be adapted into Paper image components.
merge
Package merge implements PDF merge.
Package merge implements PDF merge.
metrics
Package metrics contains metrics models, constants and formatting.
Package metrics contains metrics models, constants and formatting.
props
Package props contain the public properties of paper.
Package props contain the public properties of paper.
reader
Package reader parses existing PDF files and exposes basic page metadata, content streams, text extraction, and merge conveniences.
Package reader parses existing PDF files and exposes basic page metadata, content streams, text extraction, and merge conveniences.
sign
Package sign provides signing primitives used by PDF signature workflows.
Package sign provides signing primitives used by PDF signature workflows.
svg
Package svg parses SVG markup and adapts it to Paper components.
Package svg parses SVG markup and adapts it to Paper components.
test
Package test exposes Paper's golden-structure test helper for library consumers.
Package test exposes Paper's golden-structure test helper for library consumers.
tmpl
Package tmpl renders Go html/templates through Paper's HTML-to-PDF pipeline.
Package tmpl renders Go html/templates through Paper's HTML-to-PDF pipeline.
tree/node
Package node provides a small generic tree node used to describe Paper document structure.
Package node provides a small generic tree node used to describe Paper document structure.

Jump to

Keyboard shortcuts

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