Documentation
¶
Overview ¶
Package pdf extracts text and direction-aware glyph geometry from PDF files.
Extract returns per-page glyph quads and baselines; Page.Text reconstructs plain text by clustering direction-compatible glyphs into lines and inserting word spacing derived from glyph gaps and font metrics.
The package is pure Go with no external dependencies. It implements the PDF object layer (cross-reference tables and streams, object streams, stream filters, and password-aware standard-handler decryption) natively per ISO 32000, and on top of it a content-stream lexer, interpreter, and font decoder tuned for real-world files: it descends into Form XObjects (where e.g. Google Docs exports keep their text), honors /ToUnicode even alongside an /Encoding dictionary, tracks positions through every text operator, honors tagged-PDF replacement text, never loops on tokens straddling /Contents array segments, and reports bounded partial extraction caused by decompression bombs, stalled filter chains, or work limits.
Scanned pages carry images rather than text. Options.IncludeImages reports every image a page paints with its placement and data (Image), Image.Decode turns raw samples, JPEG, CCITT fax and JBIG2 into an image.Image, and Options.OCR hands the pages an OCRPolicy selects to an OCR implementation whose words join the page's glyphs. No OCR engine is bundled; ocr/tesseract is a reference implementation over the Tesseract command-line program.
Index ¶
- Variables
- type Annotation
- type CMapResolver
- type Destination
- type Document
- type FormField
- type Glyph
- type Image
- type LayoutMode
- type LayoutOptions
- type Limits
- type Line
- type Metadata
- type OCR
- type OCRFunc
- type OCRPolicy
- type OCRRequest
- type Options
- type Outline
- type Page
- type PageRange
- type Point
- type Quad
- type Rect
- type StrictError
- type Warning
- type WarningCode
Constants ¶
This section is empty.
Variables ¶
var ErrImageTooLarge = errors.New("pdf: image exceeds the pixel limit")
ErrImageTooLarge is returned by Image.Decode for an image whose pixel count exceeds Limits.MaxImagePixels.
var ErrPasswordRequired = crypt.ErrPasswordRequired
ErrPasswordRequired reports that an encrypted document could not be unlocked with the supplied password.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶ added in v0.3.0
type Annotation struct {
Subtype string
Rect Rect
Contents string
Title string
URL string
Destination Destination
}
Annotation contains text-bearing annotation and link information.
type CMapResolver ¶ added in v0.3.0
CMapResolver supplies a named predefined CMap that is not built into the package. The returned bytes use normal PDF CMap syntax. Without one, the predefined Unicode CMaps still read, from their codes, with the font's default width for characters outside ASCII; a resolver supplying them gives their exact CIDs, and so widths.
type Destination ¶ added in v0.3.0
Destination identifies a named destination or a destination on a page.
type Document ¶
type Document struct {
PageCount int
Pages []Page
Metadata Metadata
Outlines []Outline
FormFields []FormField
Warnings []Warning
}
Document is the extraction result for a whole file.
func Extract ¶
Extract parses the PDF in r and extracts every page's glyphs. Malformed pages yield whatever was decoded before the failure; a malformed file returns an error. The context is checked between pages and periodically while processing page operators and glyphs.
func ExtractPages ¶ added in v0.3.0
func ExtractPages( ctx context.Context, r io.ReaderAt, size int64, opts Options, yield func(Page) error, ) (*Document, error)
ExtractPages extracts pages one at a time and calls yield without retaining them in the returned Document. Document metadata, page count, form fields, outlines, and accumulated warnings are still returned.
func ExtractWithOptions ¶ added in v0.3.0
func ExtractWithOptions(ctx context.Context, r io.ReaderAt, size int64, opts Options) (*Document, error)
ExtractWithOptions extracts selected pages and document extras according to opts. In strict mode it returns the partial document together with the first warning as a *StrictError.
type Glyph ¶
type Glyph struct {
Text string // decoded text, non-empty
X, Y float64 // origin: where the baseline starts
// Advance is the glyph's width along the baseline in page units: its
// font width, scaled. Character and word spacing (Tc, Tw) move the
// next glyph on but are not part of this one, as poppler measures a
// glyph's box; the gap to the next glyph includes them.
Advance float64
Size float64 // effective font size
// Direction is the unit direction the baseline runs in. Ascent and
// Descent are the vectors from the baseline to the far and near
// edges of the glyph box, preserving rotation, skew, and vertical
// writing: horizontal text has Ascent spanning the font size along
// the text-space y axis and a zero Descent; vertical text reaches
// half the font size to either side of its baseline.
Direction Point
Ascent Point
Descent Point
}
Glyph is one decoded glyph (or glyph cluster) with its position in unrotated page space.
The geometry is stored compactly — a document's glyph slice is its largest allocation — and Baseline and Quad derive the full shapes. A Glyph carrying only Text, X, Y, Advance, and Size (for example one supplied by an OCR hook) is treated as upright horizontal text.
type Image ¶ added in v0.5.0
type Image struct {
Width, Height int
BitsPerComponent int
// Components is the number of samples per pixel in Data: 1 for image
// masks and Indexed images, 3 for RGB, 4 for CMYK, and so on. It is
// zero when the codec carries its own colour information (JPXDecode
// without a /ColorSpace).
Components int
// ColorSpace is the colour space family: DeviceGray, DeviceRGB,
// DeviceCMYK, Indexed, ICCBased, CalGray, CalRGB, Lab, Separation,
// DeviceN or Pattern. It is empty for an image mask, and for a
// JPXDecode image that carries its own colour space.
ColorSpace string
// ImageMask reports a stencil mask: one bit per pixel, where sample
// 0 (or 1 under a /Decode [1 0]) marks the pixels painted in the
// current fill colour. Scanned bilevel pages are often masks.
ImageMask bool
// Inline reports an inline image (BI … ID … EI) rather than an XObject.
Inline bool
Filter string
Data []byte
// contains filtered or unexported fields
}
Image is one image painted on a page — an image XObject or an inline image — with the geometry it was painted at and its data in the most directly usable form the package can supply without decoding it.
Data holds the image after decryption and the general-purpose stream filters. When Filter is empty, Data is unpacked samples: Height rows of Width × Components samples of BitsPerComponent bits each, rows padded to a byte boundary. Otherwise Filter names the image codec Data is still encoded with: DCTDecode (Data is a complete JPEG file), JPXDecode (a JPEG 2000 codestream or JP2 file), CCITTFaxDecode or JBIG2Decode. An OCR engine or image library that accepts that format can take Data as is; Decode turns the formats the package understands into an image.Image.
Soft masks, colour-key masking and rendering intent are not reported.
func (Image) Decode ¶ added in v0.5.0
Decode returns the image's pixels. Unpacked samples in the Device, Cal, ICCBased, Indexed and single-colorant Separation and DeviceN spaces, and image masks, decode at 1, 2, 4, 8 or 16 bits per component; an Indexed palette over a Separation or DeviceN space decodes in its printed colour, through the space's tint transform. DCTDecode decodes through image/jpeg, including CMYK data without the Adobe marker image/jpeg expects. JPXDecode (JPEG 2000) decodes natively at 8 bits per sample, in the dictionary's colour space when it names one and otherwise the file's own, opacity channels dropped. CCITTFaxDecode and JBIG2Decode (generic, symbol and text regions with arithmetic coding) decode natively to one-bit grey. Other colour spaces, JBIG2 features outside that subset, and JPEG 2000 beyond 16 bits per sample or with the Part 15 high-throughput coder return an error wrapping errors.ErrUnsupported. An image with more than Limits.MaxImagePixels pixels returns ErrImageTooLarge rather than allocating.
Results are *image.Gray, *image.Gray16, *image.Paletted (Indexed), *image.RGBA, *image.CMYK, or whatever image/jpeg returns. A stencil mask decodes to *image.Gray with painted pixels black. CCITT data that ends early yields the rows decoded, the rest white.
func (Image) Quad ¶ added in v0.5.0
Quad returns the region the image was painted over: its bottom-left, bottom-right, top-right and top-left corners in page space, in that order, so the first edge follows the image's top-to-bottom rows' direction and the shape reflects any rotation or skew.
func (Image) ToPage ¶ added in v0.5.0
ToPage maps a pixel position to unrotated page space: x runs right and y runs down from the image's top-left sample, so (0, 0) is the top-left corner and (Width, Height) the bottom-right. Coordinates an OCR engine reports for the image land on the page through this mapping.
type LayoutMode ¶ added in v0.3.0
type LayoutMode uint8
LayoutMode selects how Page.Text reconstructs text.
const ( // LayoutPosition groups glyphs into lines by their geometric // baselines and reads the page top to bottom, and side-by-side // columns of prose one after another: a band of lines split by a // common gutter reads column by column when a column holds prose, // while tables, whose short cells share every row, read row by row. // Text spanning the columns — a title, a full-width figure caption — // ends the band and reads in its place. LayoutPosition LayoutMode = iota // LayoutContentOrder preserves the order in which glyphs occur in content // streams, inserting line breaks only when the baseline changes. LayoutContentOrder // LayoutColumns reads every band of lines split by a common gutter // column by column, tables included: LayoutPosition's column reading // without its test for prose. LayoutColumns )
type LayoutOptions ¶ added in v0.3.0
type LayoutOptions struct {
Mode LayoutMode
// KeepOffPageText keeps text drawn wholly outside the page's media
// box, which no viewer shows and pdftotext and MuPDF do not extract:
// a Form XObject larger than the page, content positioned off it.
// Page.Glyphs reports it either way.
KeepOffPageText bool
// KeepDuplicateGlyphs keeps glyphs that repeat another on the same
// line: the same text painted at the same place and size, as fake
// bold, drop shadows, and fill-then-stroke headings are drawn. By
// default text reconstruction reads each such glyph once, as poppler
// and PDFBox do; Page.Glyphs reports every painted glyph either way.
KeepDuplicateGlyphs bool
}
LayoutOptions controls plain-text reconstruction.
type Limits ¶ added in v0.3.0
type Limits struct {
MaxStreamBytes int
MaxOperatorsPerPage int
MaxGlyphsPerPage int
MaxFormDepth int
// MaxImagesPerPage bounds how many image paintings a page is read
// for, whether or not their data is collected. Default 10,000.
MaxImagesPerPage int
// MaxImageBytesPerPage bounds the image data read for one page, over
// all its distinct images, each of which MaxStreamBytes bounds on its
// own. Images past the budget are left out with a WarningStreamLimit.
// Default 256 MiB.
MaxImageBytesPerPage int
// MaxImagePixels bounds the images Image.Decode is willing to
// allocate, in pixels. Default 64 Mi (a 600 dpi letter page is
// 34 Mi). Larger images are still reported with their encoded Data.
MaxImagePixels int
}
Limits bounds work performed on untrusted documents. Zero fields use the package defaults.
type Metadata ¶ added in v0.3.0
type Metadata struct {
Title string
Author string
Subject string
Keywords string
Creator string
Producer string
CreationDate string
ModifiedDate string
Trapped string
XMP []byte
Custom map[string]string
}
Metadata contains common document information dictionary and XMP fields. Dates retain their original PDF string representation.
type OCR ¶ added in v0.3.0
type OCR interface {
ExtractPage(context.Context, OCRRequest) ([]Glyph, error)
}
OCR supplies text for pages the content streams cannot. Implementations invoke an external renderer or OCR engine; the core package remains dependency-free. The glyphs returned are positioned in unrotated page space (Image.ToPage maps an engine's image coordinates there) and are appended to the page's glyphs; Page.OCRGlyphs counts them. Glyphs returned together with an error are kept, and the error is recorded as a WarningOCR.
Pages are OCR'd concurrently when Options.Concurrency allows: an implementation must be safe for concurrent use, or the caller sets Concurrency to one.
type OCRFunc ¶ added in v0.3.0
type OCRFunc func(context.Context, OCRRequest) ([]Glyph, error)
OCRFunc adapts a function to OCR.
func (OCRFunc) ExtractPage ¶ added in v0.3.0
ExtractPage calls f.
type OCRPolicy ¶ added in v0.5.0
type OCRPolicy uint8
OCRPolicy selects the pages an OCR implementation is asked about.
const ( // OCRTextlessPages selects pages whose content streams produced no // glyphs: scanned pages, and pages whose text was converted to // outlines. This is the default. OCRTextlessPages OCRPolicy = iota // OCRImagePages selects pages that paint at least one image, with or // without text of their own, for documents that mix typeset text and // scanned figures or stamps. OCRImagePages // OCRAllPages selects every extracted page. OCRAllPages )
type OCRRequest ¶ added in v0.3.0
OCRRequest is passed to an external OCR implementation for a page the OCRPolicy, or OCRSelect, selects. Page carries whatever the content streams yielded — its Glyphs, and its Images with their placement and encoded data — so an implementation can OCR the page's images directly, through Image.Decode or by handing the still-encoded Data to an engine that reads JPEG. Reader and Size identify the original PDF for implementations that render the page with an external renderer instead, which is what text converted to vector outlines needs.
type Options ¶ added in v0.3.0
type Options struct {
Password string
Pages []PageRange
Strict bool
Limits Limits
Layout LayoutOptions
IgnoreArtifacts bool
// IgnoreAnnotationAppearances leaves out the text that annotations
// paint over the page: filled form fields, free-text comments, stamps.
// By default a page's glyphs include it, after the page's own content,
// as a viewer shows it and as poppler and MuPDF extract it; hidden
// annotations are skipped either way. Text and choice fields are drawn
// from their values when the form asks viewers to regenerate
// appearances (/NeedAppearances) or a field has none. IncludeAnnotations
// and IncludeFormValues report annotations and field values as data,
// independently of this.
IgnoreAnnotationAppearances bool
IncludeMetadata bool
IncludeOutlines bool
IncludeAnnotations bool
IncludeFormValues bool
// IncludeImages reports the images each page paints in Page.Images,
// with their placement and their data as described by Image. Without
// it image data is never read, except for the pages an OCR
// implementation is asked about, and those pages do not retain it.
IncludeImages bool
// PreserveLigatures keeps the Unicode presentation forms U+FB00–U+FB06
// (ff fi fl ffi ffl ſt st) in glyph text. By default they fold to their letter
// sequences (ff, fi, fl, ffi, ffl, st) — the form searchers, tokenizers
// and other extractors expect — whether the glyph reached the ligature
// codepoint through a glyph name (Type1 /Differences, the standard
// encodings, an embedded font program) or through a ToUnicode CMap.
PreserveLigatures bool
CMapResolver CMapResolver
// OCR is asked for text on the pages OCRPolicy selects. It runs after
// the page's content streams are extracted, with the page's glyphs
// and images in hand.
OCR OCR
OCRPolicy OCRPolicy
// OCRSelect chooses the pages OCR is asked about, and overrides
// OCRPolicy where it is set. The three policies are the answers
// worth naming, not the only reasonable ones: a form with a typed
// header over a scanned body has glyphs, so OCRTextlessPages passes
// it by, while OCRImagePages reads every figure in a document that
// is mostly typeset. A predicate can say what the document actually
// needs — a floor on glyphs per page, a page range, a size the
// images have to reach.
//
// The page it receives is the one the content streams produced:
// Glyphs and ImageCount are set, and Images is still empty, because
// image data is read only once something asks for it. Like OCR
// itself, it is called from the page workers and must be safe for
// concurrent use; see Concurrency.
OCRSelect func(page Page) bool
// Concurrency bounds how many pages are extracted at once. Zero picks
// a worker per available processor; one extracts sequentially.
// Extraction stays deterministic either way: pages, their glyphs, and
// their warnings come out in the same order.
//
// Pages run concurrently only when nothing observable depends on the
// order they execute in. Strict stops at the first warning, and
// CMapResolver is caller code that need not be safe for concurrent
// use, so those extract sequentially whatever this is set to. OCR
// implementations are called concurrently, since OCR dominates the
// cost of a scanned document; set Concurrency to one for an engine
// that cannot share.
Concurrency int
}
Options controls extraction. Its zero value preserves Extract's permissive, all-pages behavior.
type Outline ¶ added in v0.3.0
type Outline struct {
Title string
Destination Destination
Children []Outline
}
Outline is one bookmark in the document outline tree.
type Page ¶
type Page struct {
Number int
// Glyphs holds the page's text in content order. Glyphs an OCR
// implementation supplied come last; OCRGlyphs counts them.
Glyphs []Glyph
// OCRGlyphs is the number of trailing Glyphs the OCR implementation
// supplied rather than the content streams.
OCRGlyphs int
// Images holds the images the page paints, in content order, when
// Options.IncludeImages is set.
Images []Image
// ImageCount is how many images the page paints, reported whether or
// not their data was read — Images is empty without
// Options.IncludeImages, and this is not.
//
// It is what separates the two reasons a page can yield no glyphs. A
// page that paints images is a scan, and an OCR implementation can
// read it; a page that paints none has had its text converted to
// vector outlines, which needs a renderer instead, or is simply
// blank. Nothing else in the result tells those apart.
ImageCount int
MediaBox Rect
CropBox Rect
Rotation int
Annotations []Annotation
Warnings []Warning
// contains filtered or unexported fields
}
Page holds the glyphs of one page in content order.
func (Page) GlyphsIn ¶ added in v0.3.0
GlyphsIn returns glyphs whose quadrilateral intersects region.
func (Page) Text ¶
Text reconstructs a page's plain text using glyph baselines and the layout selected at extraction time. Rotated and vertical runs retain their reading direction, and spaces are inferred from geometric gaps.
func (Page) TextIn ¶ added in v0.3.0
func (p Page) TextIn(region Rect, layout LayoutOptions) string
TextIn reconstructs text from glyphs intersecting region.
func (Page) TextWithOptions ¶ added in v0.3.0
func (p Page) TextWithOptions(layout LayoutOptions) string
TextWithOptions reconstructs page text using layout rather than the layout selected during extraction.
type PageRange ¶ added in v0.3.0
PageRange selects an inclusive, one-based page range. A Last value of zero means the final page.
type Quad ¶ added in v0.3.0
type Quad [4]Point
Quad describes a glyph-region perimeter. The first edge follows the baseline direction and the opposite edge returns toward its origin.
type StrictError ¶ added in v0.3.0
type StrictError struct {
Warning Warning
}
StrictError is returned when strict extraction encounters a condition that permissive extraction would record as a Warning.
func (*StrictError) Error ¶ added in v0.3.0
func (e *StrictError) Error() string
func (*StrictError) Unwrap ¶ added in v0.3.0
func (e *StrictError) Unwrap() error
type Warning ¶ added in v0.3.0
type Warning struct {
Page int
Code WarningCode
Err error
}
Warning describes a condition that may have made an extraction incomplete. Page is one-based, or zero for a document-level warning.
type WarningCode ¶ added in v0.3.0
type WarningCode string
WarningCode identifies a recoverable extraction problem.
const ( // WarningMalformedDocument reports malformed document-level structures // such as outlines or form-field trees. WarningMalformedDocument WarningCode = "malformed_document" // WarningMalformedPage reports malformed page content or page extras. WarningMalformedPage WarningCode = "malformed_page" // WarningStream reports a stream decoding or filter failure. WarningStream WarningCode = "stream_error" // WarningStreamLimit reports decoded data truncated at a configured limit. WarningStreamLimit WarningCode = "stream_limit" // WarningWorkLimit reports an operator, glyph, or nesting budget. WarningWorkLimit WarningCode = "work_limit" // WarningUnsupported reports a recoverable unsupported PDF feature. WarningUnsupported WarningCode = "unsupported" // WarningOCR reports an external OCR implementation failure. WarningOCR WarningCode = "ocr" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
cjk
Package cjk maps the CIDs of Adobe's Chinese, Japanese, and Korean character collections to Unicode, for fonts that give no other way to read their text: no ToUnicode map, and a font program with no cmap.
|
Package cjk maps the CIDs of Adobe's Chinese, Japanese, and Korean character collections to Unicode, for fonts that give no other way to read their text: no ToUnicode map, and a font program with no cmap. |
|
cjk/internal/gen
command
Command gen builds the CID→Unicode tables of package cjk from Adobe's Unicode CMaps (github.com/adobe-type-tools/cmap-resources, BSD-3-Clause):
|
Command gen builds the CID→Unicode tables of package cjk from Adobe's Unicode CMaps (github.com/adobe-type-tools/cmap-resources, BSD-3-Clause): |
|
codec/ccitt
Package ccitt decodes CCITT Group 3 and Group 4 fax coding: the one-dimensional modified Huffman (MH) and two-dimensional modified READ (MR) schemes of ITU-T T.4 and the modified modified READ (MMR) scheme of ITU-T T.6.
|
Package ccitt decodes CCITT Group 3 and Group 4 fax coding: the one-dimensional modified Huffman (MH) and two-dimensional modified READ (MR) schemes of ITU-T T.4 and the modified modified READ (MMR) scheme of ITU-T T.6. |
|
codec/dct
Package dct decodes the PDF DCTDecode filter's JPEG data (ISO 32000-1 §7.4.8) through image/jpeg, bridging where PDF writers and image/jpeg disagree.
|
Package dct decodes the PDF DCTDecode filter's JPEG data (ISO 32000-1 §7.4.8) through image/jpeg, bridging where PDF writers and image/jpeg disagree. |
|
codec/jbig2
Package jbig2 decodes the JBIG2 bi-level images embedded in PDF files through the JBIG2Decode filter (ISO 32000-1 §7.4.7): the "embedded stream" organisation of ITU-T T.88 Annex D.3, a sequence of segments without a file header, optionally preceded by the shared segments of a /JBIG2Globals stream.
|
Package jbig2 decodes the JBIG2 bi-level images embedded in PDF files through the JBIG2Decode filter (ISO 32000-1 §7.4.7): the "embedded stream" organisation of ITU-T T.88 Annex D.3, a sequence of segments without a file header, optionally preceded by the shared segments of a /JBIG2Globals stream. |
|
codec/jpx
Package jpx decodes JPEG 2000 (ITU-T T.800 | ISO/IEC 15444-1), the coding of the PDF JPXDecode filter (ISO 32000-1 §7.4.9): JP2 files and bare codestreams.
|
Package jpx decodes JPEG 2000 (ITU-T T.800 | ISO/IEC 15444-1), the coding of the PDF JPXDecode filter (ISO 32000-1 §7.4.9): JP2 files and bare codestreams. |
|
codec/mq
Package mq is the MQ adaptive binary arithmetic decoder shared by JBIG2 (ITU-T T.88 Annex E) and JPEG 2000 (ITU-T T.800 Annex C): the same coder, probability table and byte-stuffing convention.
|
Package mq is the MQ adaptive binary arithmetic decoder shared by JBIG2 (ITU-T T.88 Annex E) and JPEG 2000 (ITU-T T.800 Annex C): the same coder, probability table and byte-stuffing convention. |
|
crypt
Package crypt implements the PDF standard security handler (ISO 32000-1 §7.6.3 and ISO 32000-2 §7.6.4): RC4 and AES stream/string decryption with the file key derived from a supplied user or owner password.
|
Package crypt implements the PDF standard security handler (ISO 32000-1 §7.6.3 and ISO 32000-2 §7.6.4): RC4 and AES stream/string decryption with the file key derived from a supplied user or owner password. |
|
encoding
Package encoding implements the simple-font character encodings of ISO 32000-1 Annex D and the Adobe Glyph List glyph-name algorithm.
|
Package encoding implements the simple-font character encodings of ISO 32000-1 Annex D and the Adobe Glyph List glyph-name algorithm. |
|
filter
Package filter implements the PDF stream decode filters of ISO 32000-1 §7.4 that text extraction needs: FlateDecode, LZWDecode, ASCIIHexDecode, ASCII85Decode and RunLengthDecode, with the PNG and TIFF predictors.
|
Package filter implements the PDF stream decode filters of ISO 32000-1 §7.4 that text extraction needs: FlateDecode, LZWDecode, ASCIIHexDecode, ASCII85Decode and RunLengthDecode, with the PNG and TIFF predictors. |
|
function
Package function evaluates PDF functions (ISO 32000-1 §7.10): sampled (type 0), exponential interpolation (type 2), stitching (type 3) and PostScript calculator (type 4).
|
Package function evaluates PDF functions (ISO 32000-1 §7.10): sampled (type 0), exponential interpolation (type 2), stitching (type 3) and PostScript calculator (type 4). |
|
object
Package object is a native PDF object layer: a lexer and parser for the COS object syntax (ISO 32000-1 §7.2–7.3), cross-reference tables and streams (§7.5), and a Value model for navigating the resulting object graph.
|
Package object is a native PDF object layer: a lexer and parser for the COS object syntax (ISO 32000-1 §7.2–7.3), cross-reference tables and streams (§7.5), and a Value model for navigating the resulting object graph. |
|
safeio
Package safeio bounds reads from untrusted streams: decompression bombs and stalled filter chains must cost bounded memory and CPU.
|
Package safeio bounds reads from untrusted streams: decompression bombs and stalled filter chains must cost bounded memory and CPU. |
|
stdfont
Package stdfont holds the advance widths of the 14 standard PDF fonts, which PDF 1.4 and earlier let a document use without a /Widths array, leaving the metrics to the reader.
|
Package stdfont holds the advance widths of the 14 standard PDF fonts, which PDF 1.4 and earlier let a document use without a /Widths array, leaving the metrics to the reader. |
|
stdfont/internal/gen
command
Command gen builds package stdfont's width tables from the Core 14 AFM files (Adobe; see ../../NOTICE):
|
Command gen builds package stdfont's width tables from the Core 14 AFM files (Adobe; see ../../NOTICE): |
|
ocr
|
|
|
tesseract
Package tesseract implements pdf.OCR with the Tesseract command-line program, as a reference for plugging an OCR engine into github.com/giraffesyo/pdf: it OCRs the images a page paints and places the recognized words on the page through pdf.Image.ToPage, so they flow into Page.Text and the layout modes like typeset text.
|
Package tesseract implements pdf.OCR with the Tesseract command-line program, as a reference for plugging an OCR engine into github.com/giraffesyo/pdf: it OCRs the images a page paints and places the recognized words on the page through pdf.Image.ToPage, so they flow into Page.Text and the layout modes like typeset text. |
|
Package pdftest builds minimal synthetic PDF files for tests, in the spirit of net/http/httptest.
|
Package pdftest builds minimal synthetic PDF files for tests, in the spirit of net/http/httptest. |