Documentation
¶
Overview ¶
Package pdf implements reading of PDF files.
Overview ¶
PDF is Adobe's Portable Document Format, ubiquitous on the internet. A PDF document is a complex data format built on a fairly simple structure. This package exposes the simple structure along with some wrappers to extract basic information. If more complex information is needed, it is possible to extract that information by interpreting the structure exposed by this package.
Specifically, a PDF is a data structure built from Values, each of which has one of the following Kinds:
Null, for the null object. Integer, for an integer. Real, for a floating-point number. Bool, for a boolean value. Name, for a name constant (as in /Helvetica). String, for a string constant. Dict, for a dictionary of name-value pairs. Array, for an array of values. Stream, for an opaque data stream and associated header dictionary.
The accessors on Value—Int64, Float64, Bool, Name, and so on—return a view of the data as the given type. When there is no appropriate view, the accessor returns a zero result. For example, the Name accessor returns the empty string if called on a Value v for which v.Kind() != Name. Returning zero values this way, especially from the Dict and Array accessors, which themselves return Values, makes it possible to traverse a PDF quickly without writing any error checking. On the other hand, it means that mistakes can go unreported.
The basic structure of the PDF file is exposed as the graph of Values.
Most richer data structures in a PDF file are dictionaries with specific interpretations of the name-value pairs. The Font and Page wrappers make the interpretation of a specific Value as the corresponding type easier. They are only helpers, though: they are implemented only in terms of the Value API and could be moved outside the package. Equally important, traversal of other PDF data structures can be implemented in other packages as needed.
Example ¶
package main
import (
"fmt"
"github.com/atlas-editor/pdf"
)
func main() {
fp, _ := pdf.Open("testdata/pdfreference1.0.pdf")
chars, lines, curves, rects, imgs := 0, 0, 0, 0, 0
for n := 1; n < fp.NumPage()+1; n++ {
page := fp.Page(n)
content := page.Content()
chars += len(content.Chars)
lines += len(content.Lines)
curves += len(content.Curves)
rects += len(content.Rectangles)
imgs += len(content.Images)
if n == 1 {
for _, ch := range content.Chars[:18] {
fmt.Print(ch.S)
}
fmt.Print("\n\n")
}
}
fmt.Printf("chars=%v\nlines=%v\ncurves=%v\nrectangles=%v\nimages=%v\n==========\ncomponents=%v\n",
chars, lines, curves, rects, imgs, imgs+rects+chars+lines+curves)
}
Output: PDFReferenceManual chars=289172 lines=599 curves=634 rectangles=8251 images=15 ========== components=298671
Index ¶
- Variables
- func Interpret(strm Value, do func(stk *Stack, op string))
- type Char
- type Content
- type Curve
- type Font
- type Image
- type Interpreter
- type Line
- type Number
- type Outline
- type Page
- type Point
- type Reader
- type ReaderAtCloser
- type Rectangle
- type Segment
- type Stack
- type TextEncoding
- type TextHorizontal
- type TextVertical
- type Value
- func (v Value) Bool() bool
- func (v Value) Float64() float64
- func (v Value) Index(i int) Value
- func (v Value) Int64() int64
- func (v Value) IsNull() bool
- func (v Value) Key(key string) Value
- func (v Value) Keys() []string
- func (v Value) Kind() ValueKind
- func (v Value) Len() int
- func (v Value) Name() string
- func (v Value) RawString() string
- func (v Value) Reader() io.ReadCloser
- func (v Value) String() string
- func (v Value) Text() string
- func (v Value) TextFromUTF16() string
- type ValueKind
- Bugs
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Core14Widths = map[string][]float64{ "Helvetica-BoldOblique": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 278.0, 333.0, 474.0, 556.0, 556.0, 889.0, 722.0, 278.0, 333.0, 333.0, 389.0, 584.0, 278.0, 333.0, 278.0, 278.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 333.0, 333.0, 584.0, 584.0, 584.0, 611.0, 975.0, 722.0, 722.0, 722.0, 722.0, 667.0, 611.0, 778.0, 722.0, 278.0, 556.0, 722.0, 611.0, 833.0, 722.0, 778.0, 667.0, 778.0, 722.0, 667.0, 611.0, 722.0, 667.0, 944.0, 667.0, 667.0, 611.0, 333.0, 278.0, 333.0, 584.0, 556.0, 278.0, 556.0, 611.0, 556.0, 611.0, 556.0, 333.0, 611.0, 611.0, 278.0, 278.0, 556.0, 278.0, 889.0, 611.0, 611.0, 611.0, 611.0, 389.0, 556.0, 333.0, 611.0, 556.0, 778.0, 556.0, 556.0, 500.0, 389.0, 280.0, 389.0, 584.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 556.0, 556.0, 167.0, 556.0, 556.0, 556.0, 556.0, 238.0, 500.0, 556.0, 333.0, 333.0, 611.0, 611.0, 0.0, 556.0, 556.0, 556.0, 278.0, 0.0, 556.0, 350.0, 278.0, 500.0, 500.0, 556.0, 1000.0, 1000.0, 0.0, 611.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 370.0, 0.0, 0.0, 0.0, 0.0, 611.0, 778.0, 1000.0, 365.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 611.0, 944.0, 611.0, 0.0, 0.0, 0.0, 556.0, }, "ZapfDingbats": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 278.0, 974.0, 961.0, 974.0, 980.0, 719.0, 789.0, 790.0, 791.0, 690.0, 960.0, 939.0, 549.0, 855.0, 911.0, 933.0, 911.0, 945.0, 974.0, 755.0, 846.0, 762.0, 761.0, 571.0, 677.0, 763.0, 760.0, 759.0, 754.0, 494.0, 552.0, 537.0, 577.0, 692.0, 786.0, 788.0, 788.0, 790.0, 793.0, 794.0, 816.0, 823.0, 789.0, 841.0, 823.0, 833.0, 816.0, 831.0, 923.0, 744.0, 723.0, 749.0, 790.0, 792.0, 695.0, 776.0, 768.0, 792.0, 759.0, 707.0, 708.0, 682.0, 701.0, 826.0, 815.0, 789.0, 789.0, 707.0, 687.0, 696.0, 689.0, 786.0, 787.0, 713.0, 791.0, 785.0, 791.0, 873.0, 761.0, 762.0, 762.0, 759.0, 759.0, 892.0, 892.0, 788.0, 784.0, 438.0, 138.0, 277.0, 415.0, 392.0, 392.0, 668.0, 668.0, 0.0, 390.0, 390.0, 317.0, 317.0, 276.0, 276.0, 509.0, 509.0, 410.0, 410.0, 234.0, 234.0, 334.0, 334.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 732.0, 544.0, 544.0, 910.0, 667.0, 760.0, 760.0, 776.0, 595.0, 694.0, 626.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 788.0, 894.0, 838.0, 1016.0, 458.0, 748.0, 924.0, 748.0, 918.0, 927.0, 928.0, 928.0, 834.0, 873.0, 828.0, 924.0, 924.0, 917.0, 930.0, 931.0, 463.0, 883.0, 836.0, 836.0, 867.0, 867.0, 696.0, 696.0, 874.0, 0.0, 874.0, 760.0, 946.0, 771.0, 865.0, 771.0, 888.0, 967.0, 888.0, 831.0, 873.0, 927.0, 970.0, 918.0, 0.0, }, "Helvetica-Bold": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 278.0, 333.0, 474.0, 556.0, 556.0, 889.0, 722.0, 278.0, 333.0, 333.0, 389.0, 584.0, 278.0, 333.0, 278.0, 278.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 333.0, 333.0, 584.0, 584.0, 584.0, 611.0, 975.0, 722.0, 722.0, 722.0, 722.0, 667.0, 611.0, 778.0, 722.0, 278.0, 556.0, 722.0, 611.0, 833.0, 722.0, 778.0, 667.0, 778.0, 722.0, 667.0, 611.0, 722.0, 667.0, 944.0, 667.0, 667.0, 611.0, 333.0, 278.0, 333.0, 584.0, 556.0, 278.0, 556.0, 611.0, 556.0, 611.0, 556.0, 333.0, 611.0, 611.0, 278.0, 278.0, 556.0, 278.0, 889.0, 611.0, 611.0, 611.0, 611.0, 389.0, 556.0, 333.0, 611.0, 556.0, 778.0, 556.0, 556.0, 500.0, 389.0, 280.0, 389.0, 584.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 556.0, 556.0, 167.0, 556.0, 556.0, 556.0, 556.0, 238.0, 500.0, 556.0, 333.0, 333.0, 611.0, 611.0, 0.0, 556.0, 556.0, 556.0, 278.0, 0.0, 556.0, 350.0, 278.0, 500.0, 500.0, 556.0, 1000.0, 1000.0, 0.0, 611.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 370.0, 0.0, 0.0, 0.0, 0.0, 611.0, 778.0, 1000.0, 365.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 611.0, 944.0, 611.0, 0.0, 0.0, 0.0, 556.0, }, "Courier-Oblique": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 600.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 600.0, }, "Courier": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 600.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 600.0, }, "Helvetica": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 278.0, 278.0, 355.0, 556.0, 556.0, 889.0, 667.0, 222.0, 333.0, 333.0, 389.0, 584.0, 278.0, 333.0, 278.0, 278.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 278.0, 278.0, 584.0, 584.0, 584.0, 556.0, 1015.0, 667.0, 667.0, 722.0, 722.0, 667.0, 611.0, 778.0, 722.0, 278.0, 500.0, 667.0, 556.0, 833.0, 722.0, 778.0, 667.0, 778.0, 722.0, 667.0, 611.0, 722.0, 667.0, 944.0, 667.0, 667.0, 611.0, 278.0, 278.0, 278.0, 469.0, 556.0, 222.0, 556.0, 556.0, 500.0, 556.0, 556.0, 278.0, 556.0, 556.0, 222.0, 222.0, 500.0, 222.0, 833.0, 556.0, 556.0, 556.0, 556.0, 333.0, 500.0, 278.0, 556.0, 500.0, 722.0, 500.0, 500.0, 500.0, 334.0, 260.0, 334.0, 584.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 556.0, 556.0, 167.0, 556.0, 556.0, 556.0, 556.0, 191.0, 333.0, 556.0, 333.0, 333.0, 500.0, 500.0, 0.0, 556.0, 556.0, 556.0, 278.0, 0.0, 537.0, 350.0, 222.0, 333.0, 333.0, 556.0, 1000.0, 1000.0, 0.0, 611.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 370.0, 0.0, 0.0, 0.0, 0.0, 556.0, 778.0, 1000.0, 365.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 222.0, 611.0, 944.0, 611.0, 0.0, 0.0, 0.0, 556.0, }, "Symbol": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 250.0, 333.0, 713.0, 500.0, 549.0, 833.0, 778.0, 439.0, 333.0, 333.0, 500.0, 549.0, 250.0, 549.0, 250.0, 278.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 278.0, 278.0, 549.0, 549.0, 549.0, 444.0, 549.0, 722.0, 667.0, 722.0, 612.0, 611.0, 763.0, 603.0, 722.0, 333.0, 631.0, 722.0, 686.0, 889.0, 722.0, 722.0, 768.0, 741.0, 556.0, 592.0, 611.0, 690.0, 439.0, 768.0, 645.0, 795.0, 611.0, 333.0, 863.0, 333.0, 658.0, 500.0, 500.0, 631.0, 549.0, 549.0, 494.0, 439.0, 521.0, 411.0, 603.0, 329.0, 603.0, 549.0, 549.0, 576.0, 521.0, 549.0, 549.0, 521.0, 549.0, 603.0, 439.0, 576.0, 713.0, 686.0, 493.0, 686.0, 494.0, 480.0, 200.0, 480.0, 549.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 750.0, 620.0, 247.0, 549.0, 167.0, 713.0, 500.0, 753.0, 753.0, 753.0, 753.0, 1042.0, 987.0, 603.0, 987.0, 603.0, 400.0, 549.0, 411.0, 549.0, 549.0, 713.0, 494.0, 460.0, 549.0, 549.0, 549.0, 549.0, 1000.0, 603.0, 1000.0, 658.0, 823.0, 686.0, 795.0, 987.0, 768.0, 768.0, 823.0, 768.0, 768.0, 713.0, 713.0, 713.0, 713.0, 713.0, 713.0, 713.0, 768.0, 713.0, 790.0, 790.0, 890.0, 823.0, 549.0, 250.0, 713.0, 603.0, 603.0, 1042.0, 987.0, 603.0, 987.0, 603.0, 494.0, 329.0, 790.0, 790.0, 786.0, 713.0, 384.0, 384.0, 384.0, 384.0, 384.0, 384.0, 494.0, 494.0, 494.0, 494.0, 0.0, 329.0, 274.0, 686.0, 686.0, 686.0, 384.0, 384.0, 384.0, 384.0, 384.0, 384.0, 494.0, 494.0, 494.0, 790.0, }, "Times-BoldItalic": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 250.0, 389.0, 555.0, 500.0, 500.0, 833.0, 778.0, 333.0, 333.0, 333.0, 500.0, 570.0, 250.0, 333.0, 250.0, 278.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 333.0, 333.0, 570.0, 570.0, 570.0, 500.0, 832.0, 667.0, 667.0, 667.0, 722.0, 667.0, 667.0, 722.0, 778.0, 389.0, 500.0, 667.0, 611.0, 889.0, 722.0, 722.0, 611.0, 722.0, 667.0, 556.0, 611.0, 722.0, 667.0, 889.0, 667.0, 611.0, 611.0, 333.0, 278.0, 333.0, 570.0, 500.0, 333.0, 500.0, 500.0, 444.0, 500.0, 444.0, 333.0, 500.0, 556.0, 278.0, 278.0, 500.0, 278.0, 778.0, 556.0, 500.0, 500.0, 500.0, 389.0, 389.0, 278.0, 556.0, 444.0, 667.0, 500.0, 444.0, 389.0, 348.0, 220.0, 348.0, 570.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 389.0, 500.0, 500.0, 167.0, 500.0, 500.0, 500.0, 500.0, 278.0, 500.0, 500.0, 333.0, 333.0, 556.0, 556.0, 0.0, 500.0, 500.0, 500.0, 250.0, 0.0, 500.0, 350.0, 333.0, 500.0, 500.0, 500.0, 1000.0, 1000.0, 0.0, 500.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 944.0, 0.0, 266.0, 0.0, 0.0, 0.0, 0.0, 611.0, 722.0, 944.0, 300.0, 0.0, 0.0, 0.0, 0.0, 0.0, 722.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 500.0, 722.0, 500.0, 0.0, 0.0, 0.0, 500.0, }, "Courier-Bold": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 600.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 600.0, }, "Times-Roman": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 250.0, 333.0, 408.0, 500.0, 500.0, 833.0, 778.0, 333.0, 333.0, 333.0, 500.0, 564.0, 250.0, 333.0, 250.0, 278.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 278.0, 278.0, 564.0, 564.0, 564.0, 444.0, 921.0, 722.0, 667.0, 667.0, 722.0, 611.0, 556.0, 722.0, 722.0, 333.0, 389.0, 722.0, 611.0, 889.0, 722.0, 722.0, 556.0, 722.0, 667.0, 556.0, 611.0, 722.0, 722.0, 944.0, 722.0, 722.0, 611.0, 333.0, 278.0, 333.0, 469.0, 500.0, 333.0, 444.0, 500.0, 444.0, 500.0, 444.0, 333.0, 500.0, 500.0, 278.0, 278.0, 500.0, 278.0, 778.0, 500.0, 500.0, 500.0, 500.0, 333.0, 389.0, 278.0, 500.0, 500.0, 722.0, 500.0, 500.0, 444.0, 480.0, 200.0, 480.0, 541.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 500.0, 500.0, 167.0, 500.0, 500.0, 500.0, 500.0, 180.0, 444.0, 500.0, 333.0, 333.0, 556.0, 556.0, 0.0, 500.0, 500.0, 500.0, 250.0, 0.0, 453.0, 350.0, 333.0, 444.0, 444.0, 500.0, 1000.0, 1000.0, 0.0, 444.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 276.0, 0.0, 0.0, 0.0, 0.0, 611.0, 722.0, 889.0, 310.0, 0.0, 0.0, 0.0, 0.0, 0.0, 667.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 500.0, 722.0, 500.0, 0.0, 0.0, 0.0, 500.0, }, "Times-Bold": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 250.0, 333.0, 555.0, 500.0, 500.0, 1000.0, 833.0, 333.0, 333.0, 333.0, 500.0, 570.0, 250.0, 333.0, 250.0, 278.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 333.0, 333.0, 570.0, 570.0, 570.0, 500.0, 930.0, 722.0, 667.0, 722.0, 722.0, 667.0, 611.0, 778.0, 778.0, 389.0, 500.0, 778.0, 667.0, 944.0, 722.0, 778.0, 611.0, 778.0, 722.0, 556.0, 667.0, 722.0, 722.0, 1000.0, 722.0, 722.0, 667.0, 333.0, 278.0, 333.0, 581.0, 500.0, 333.0, 500.0, 556.0, 444.0, 556.0, 444.0, 333.0, 500.0, 556.0, 278.0, 333.0, 556.0, 278.0, 833.0, 556.0, 500.0, 556.0, 556.0, 444.0, 389.0, 333.0, 556.0, 500.0, 722.0, 500.0, 500.0, 444.0, 394.0, 220.0, 394.0, 520.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 500.0, 500.0, 167.0, 500.0, 500.0, 500.0, 500.0, 278.0, 500.0, 500.0, 333.0, 333.0, 556.0, 556.0, 0.0, 500.0, 500.0, 500.0, 250.0, 0.0, 540.0, 350.0, 333.0, 500.0, 500.0, 500.0, 1000.0, 1000.0, 0.0, 500.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 300.0, 0.0, 0.0, 0.0, 0.0, 667.0, 778.0, 1000.0, 330.0, 0.0, 0.0, 0.0, 0.0, 0.0, 722.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 500.0, 722.0, 556.0, 0.0, 0.0, 0.0, 500.0, }, "Helvetica-Oblique": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 278.0, 278.0, 355.0, 556.0, 556.0, 889.0, 667.0, 222.0, 333.0, 333.0, 389.0, 584.0, 278.0, 333.0, 278.0, 278.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 556.0, 278.0, 278.0, 584.0, 584.0, 584.0, 556.0, 1015.0, 667.0, 667.0, 722.0, 722.0, 667.0, 611.0, 778.0, 722.0, 278.0, 500.0, 667.0, 556.0, 833.0, 722.0, 778.0, 667.0, 778.0, 722.0, 667.0, 611.0, 722.0, 667.0, 944.0, 667.0, 667.0, 611.0, 278.0, 278.0, 278.0, 469.0, 556.0, 222.0, 556.0, 556.0, 500.0, 556.0, 556.0, 278.0, 556.0, 556.0, 222.0, 222.0, 500.0, 222.0, 833.0, 556.0, 556.0, 556.0, 556.0, 333.0, 500.0, 278.0, 556.0, 500.0, 722.0, 500.0, 500.0, 500.0, 334.0, 260.0, 334.0, 584.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 333.0, 556.0, 556.0, 167.0, 556.0, 556.0, 556.0, 556.0, 191.0, 333.0, 556.0, 333.0, 333.0, 500.0, 500.0, 0.0, 556.0, 556.0, 556.0, 278.0, 0.0, 537.0, 350.0, 222.0, 333.0, 333.0, 556.0, 1000.0, 1000.0, 0.0, 611.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 1000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 370.0, 0.0, 0.0, 0.0, 0.0, 556.0, 778.0, 1000.0, 365.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 222.0, 611.0, 944.0, 611.0, 0.0, 0.0, 0.0, 556.0, }, "Times-Italic": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 250.0, 333.0, 420.0, 500.0, 500.0, 833.0, 778.0, 333.0, 333.0, 333.0, 500.0, 675.0, 250.0, 333.0, 250.0, 278.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 500.0, 333.0, 333.0, 675.0, 675.0, 675.0, 500.0, 920.0, 611.0, 611.0, 667.0, 722.0, 611.0, 611.0, 722.0, 722.0, 333.0, 444.0, 667.0, 556.0, 833.0, 667.0, 722.0, 611.0, 722.0, 611.0, 500.0, 556.0, 722.0, 611.0, 833.0, 611.0, 556.0, 556.0, 389.0, 278.0, 389.0, 422.0, 500.0, 333.0, 500.0, 500.0, 444.0, 500.0, 444.0, 278.0, 500.0, 500.0, 278.0, 278.0, 444.0, 278.0, 722.0, 500.0, 500.0, 500.0, 500.0, 389.0, 389.0, 278.0, 500.0, 444.0, 667.0, 444.0, 444.0, 389.0, 400.0, 275.0, 400.0, 541.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 389.0, 500.0, 500.0, 167.0, 500.0, 500.0, 500.0, 500.0, 214.0, 556.0, 500.0, 333.0, 333.0, 500.0, 500.0, 0.0, 500.0, 500.0, 500.0, 250.0, 0.0, 523.0, 350.0, 333.0, 556.0, 556.0, 500.0, 889.0, 1000.0, 0.0, 500.0, 0.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 333.0, 0.0, 333.0, 333.0, 0.0, 333.0, 333.0, 333.0, 889.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 889.0, 0.0, 276.0, 0.0, 0.0, 0.0, 0.0, 556.0, 722.0, 944.0, 310.0, 0.0, 0.0, 0.0, 0.0, 0.0, 667.0, 0.0, 0.0, 0.0, 278.0, 0.0, 0.0, 278.0, 500.0, 667.0, 500.0, 0.0, 0.0, 0.0, 500.0, }, "Courier-BoldOblique": []float64{ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 600.0, 0.0, 600.0, 600.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 600.0, 0.0, 0.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 0.0, 600.0, 0.0, 0.0, 600.0, 600.0, 600.0, 600.0, 0.0, 0.0, 0.0, 600.0, }, }
var ErrInvalidPassword = fmt.Errorf("encrypted PDF: invalid password")
Functions ¶
func Interpret ¶
Interpret interprets the content in a stream as a basic PostScript program, pushing values onto a stack and then calling the do function to execute operators. The do function may push or pop values from the stack as needed to implement op.
Interpret handles the operators "dict", "currentdict", "begin", "end", "def", and "pop" itself.
Interpret is not a full-blown PostScript interpreter. Its job is to handle the very limited PostScript found in certain supporting file formats embedded in PDF files, such as cmap files that describe the mapping from font code points to Unicode code points.
There is no support for executable blocks, among other limitations.
Types ¶
type Char ¶
type Char struct {
Font string // the font used
FontSize float64 // the font size, in points (1/72 of an inch)
X float64 // the X coordinate, in points, increasing left to right
Y float64 // the Y coordinate, in points, increasing bottom to top
W float64 // the width of the char, in points
S string // the actual UTF-8 text
}
A Char represents a single piece of text drawn on a page.
type Content ¶
type Content struct {
Chars []Char
Rectangles []Rectangle
Lines []Line
Curves []Curve
Images []Image
}
Content describes the basic content on a page: the text and any drawn rectangles.
type Curve ¶
type Curve struct {
Segments []Segment
}
A Curve represents a general non-rectangle non-line curve .
type Font ¶
type Font struct {
V Value
}
A Font represent a font in a PDF file. The methods interpret a Font dictionary stored in V.
func (Font) Encoder ¶
func (f Font) Encoder() TextEncoding
Encoder returns the encoding between font code point sequences and UTF-8.
type Image ¶
type Image struct {
P0, P1, P2, P3 Point
Data io.ReadCloser
// contains filtered or unexported fields
}
An Image represents an embedded image with its anchor points wrt to the document's media box.
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter(rsrcs Value) *Interpreter
func (*Interpreter) InterpretContentStream ¶
func (interp *Interpreter) InterpretContentStream(strm Value) Content
type Outline ¶
An Outline is a tree describing the outline (also known as the table of contents) of a document.
type Page ¶
type Page struct {
V Value
}
A Page represent a single page in a PDF file. The methods interpret a Page dictionary stored in V.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A Reader is a single PDF file open for reading.
func NewReader ¶
func NewReader(f ReaderAtCloser, size int64) (*Reader, error)
NewReader opens a file for reading, using the data in f with the given total size.
func NewReaderEncrypted ¶
func NewReaderEncrypted(f ReaderAtCloser, size int64, pw func() string) (*Reader, error)
NewReaderEncrypted opens a file for reading, using the data in f with the given total size. If the PDF is encrypted, NewReaderEncrypted calls pw repeatedly to obtain passwords to try. If pw returns the empty string, NewReaderEncrypted stops trying to decrypt the file and returns an error.
func (*Reader) Outline ¶
Outline returns the document outline. The Outline returned is the root of the outline tree and typically has no Title itself. That is, the children of the returned root are the top-level entries in the outline.
type ReaderAtCloser ¶
ReaderAtCloser combines the io.ReaderAt and io.Closer interfaces.
type Segment ¶
A Segment represents a path's segment, see Table 4.9 (Chap. 4, PDF 1.7 Reference, 6th Ed.).
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
A Stack represents a stack of values.
type TextEncoding ¶
type TextEncoding interface {
// Decode returns the UTF-8 text corresponding to
// the sequence of code points in data.
Decode(raw string) (text string)
}
A TextEncoding represents a mapping between font code points and UTF-8 text.
type TextHorizontal ¶
type TextHorizontal []Char
TextHorizontal implements sort.Interface for sorting a slice of Text values in horizontal order, left to right, and then top to bottom within a column.
func (TextHorizontal) Len ¶
func (x TextHorizontal) Len() int
func (TextHorizontal) Less ¶
func (x TextHorizontal) Less(i, j int) bool
func (TextHorizontal) Swap ¶
func (x TextHorizontal) Swap(i, j int)
type TextVertical ¶
type TextVertical []Char
TextVertical implements sort.Interface for sorting a slice of Text values in vertical order, top to bottom, and then left to right within a line.
func (TextVertical) Len ¶
func (x TextVertical) Len() int
func (TextVertical) Less ¶
func (x TextVertical) Less(i, j int) bool
func (TextVertical) Swap ¶
func (x TextVertical) Swap(i, j int)
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
A Value is a single PDF value, such as an integer, dictionary, or array. The zero Value is a PDF null (Kind() == Null, IsNull() = true).
func (Value) Float64 ¶
Float64 returns v's float64 value, converting from integer if necessary. If v.Kind() != Float64 and v.Kind() != Int64, Float64 returns 0.
func (Value) Index ¶
Index returns the i'th element in the array v. If v.Kind() != Array or if i is outside the array bounds, Index returns a null Value.
func (Value) IsNull ¶
IsNull reports whether the value is a null. It is equivalent to Kind() == Null.
func (Value) Key ¶
Key returns the value associated with the given name key in the dictionary v. Like the result of the Name method, the key should not include a leading slash. If v is a stream, Key applies to the stream's header dictionary. If v.Kind() != Dict and v.Kind() != Stream, Key returns a null Value.
func (Value) Keys ¶
Keys returns a sorted list of the keys in the dictionary v. If v is a stream, Keys applies to the stream's header dictionary. If v.Kind() != Dict and v.Kind() != Stream, Keys returns nil.
func (Value) Name ¶
Name returns v's name value. If v.Kind() != Name, Name returns the empty string. The returned name does not include the leading slash: if v corresponds to the name written using the syntax /Helvetica, Name() == "Helvetica".
func (Value) RawString ¶
RawString returns v's string value. If v.Kind() != String, RawString returns the empty string.
func (Value) Reader ¶
func (v Value) Reader() io.ReadCloser
Reader returns the data contained in the stream v. If v.Kind() is not a stream or an array of streams, Reader returns a ReadCloser that responds to all reads with a “stream not present” error.
func (Value) String ¶
String returns a textual representation of the value v. Note that String is not the accessor for values with Kind() == String. To access such values, see RawString, Text, and TextFromUTF16.
func (Value) Text ¶
Text returns v's string value interpreted as a “text string” (defined in the PDF spec) and converted to UTF-8. If v.Kind() != String, Text returns the empty string.
func (Value) TextFromUTF16 ¶
TextFromUTF16 returns v's string value interpreted as big-endian UTF-16 and then converted to UTF-8. If v.Kind() != String or if the data is not valid UTF-16, TextFromUTF16 returns the empty string.
Notes ¶
Bugs ¶
The package is incomplete, although it has been used successfully on some large real-world PDF files.
The support for reading encrypted files is weak.
The Value API does not support error reporting. The intent is to allow users to set an error reporting callback in Reader, but that code has not been implemented.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Pdfpasswd searches for the password for an encrypted PDF by trying all strings over a given alphabet up to a given length.
|
Pdfpasswd searches for the password for an encrypted PDF by trying all strings over a given alphabet up to a given length. |
|
Pdftext extracts text from a PDF file, optionally specifying a page number.
|
Pdftext extracts text from a PDF file, optionally specifying a page number. |
|
Pdfvis visualizes the layout of a PDF file, optionally specifying a page number.
|
Pdfvis visualizes the layout of a PDF file, optionally specifying a page number. |