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 ¶
Copyright (c) 2017–20, Norbert Pillmayer ¶
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 ¶
- func T() tracing.Trace
- type Page
- type PageStatus
- type Printer
- func (pr *Printer) Abort(err error)
- func (pr *Printer) IsRunning() bool
- func (pr *Printer) PageCount() int
- func (pr *Printer) PrintPage(pageno int, pageGeom dimen.Rect, content *RenderTree) *Page
- func (pr *Printer) SetMaxPage(n int)
- func (pr *Printer) Start(w io.Writer) func() error
- func (pr *Printer) StatusOf(page *Page) PageStatus
- type RenderTree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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(...).
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 ¶
NewPrinter creates a new Printer, given a paper format and scale factor.
func (*Printer) Abort ¶
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 ¶
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) PrintPage ¶
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 ¶
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 ¶
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.