pdf

package
v0.1.0-experimental.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package pdf implements PDF printing, i.e. generating PDF file output.

PDF generation is done in a concurrent fashion. Clients may enqueue pages concurrently and the printer will render them concurrently. The printer will convert the pages into PDF fragments, serialize them and then assemble them into a PDF document.

BSD License

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of this software nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func T

func T() tracing.Trace

T is tracing to the EngineTracer.

Types

type Page

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

Page represents a page in the printer queue, as part of a print job. Pages will be created by Printer.PrintPage(...).

func (*Page) PageNo

func (page *Page) PageNo() int

PageNo returns the contiguous page number of a page.

type PageStatus

type PageStatus int8

PageStatus reflects a printer status for a page.

const (
	Queued     PageStatus = iota // queued for printing
	Printing                     // in print, i.e, PDF code is generated
	Assembling                   // PDF for page complete, in doc assembly
	Printed                      // already encoded as part of the document
)

Pages queued for printing may be in these states:

type Printer

type Printer struct {
	Proofing  bool // are we in proof mode?
	Colormode bool // color or b/w ?
	// contains filtered or unexported fields
}

Printer is used for outputting a render tree in PDF format.

func NewPrinter

func NewPrinter(papersize dimen.Point, scale float64) *Printer

NewPrinter creates a new Printer, given a paper format and scale factor.

func (*Printer) Abort

func (pr *Printer) Abort(err error)

Abort stops the printer. The call will block until the printer stopped. err should be nil to signal a successful completion of printing.

func (*Printer) IsRunning

func (pr *Printer) IsRunning() bool

IsRunning returns true if the printer is accepting input, false otherwise. Printers will be running after calls to Start(...) until either the expected number of pages has been printed or Abort(...) has been called.

func (*Printer) PageCount

func (pr *Printer) PageCount() int

PageCount returns the current number of completed pages.

func (*Printer) PrintPage

func (pr *Printer) PrintPage(pageno int, pageGeom dimen.Rect, content *RenderTree) *Page

PrintPage creates a new page with given page number, dimensions and content. The call automatically enqueues it into the printer queue.

The page number is intended to be a part of a contiguous series of page numbers. The printer expects pages ranging from 1..n, where n is set by SetMaxPage(n). If this constraint is violated, the printer may stall waiting for non-existent pages. Page numbers range from 0 to 32767.

func (*Printer) SetMaxPage

func (pr *Printer) SetMaxPage(n int)

SetMaxPage must be called from clients as soon as they know how many pages there will be in the print job. Page numbers range from 0 to 32767.

func (*Printer) Start

func (pr *Printer) Start(w io.Writer) func() error

Start starts printing to w. It returns a promise/future. Clients will call this promise to synchronously wait for printing to finish.

func (*Printer) StatusOf

func (pr *Printer) StatusOf(page *Page) PageStatus

StatusOf returns the print status of a page in the printer's queue.

type RenderTree

type RenderTree struct{}

TODO

Directories

Path Synopsis
Package pdfapi will implement a low-level API for the PDF format.
Package pdfapi will implement a low-level API for the PDF format.

Jump to

Keyboard shortcuts

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