pdf

package
v0.0.0-...-6541b2f Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2014 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package pdf is used for creating, reading, and editing PDF files.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsciiFromBytes

func AsciiFromBytes(b []byte) string

func AsciiStringSerializer

func AsciiStringSerializer(s String, w Writer)

func GeneralAsciiEscapeByte

func GeneralAsciiEscapeByte(b byte) (result []byte)

func HexDigit

func HexDigit(b byte) (result byte)

func HexStringSerializer

func HexStringSerializer(s String, w Writer)

func IsAlpha

func IsAlpha(b byte) bool

func IsDelimiter

func IsDelimiter(b byte) bool

Is the passed byte a PDF delimiter?

func IsDigit

func IsDigit(b byte) bool

func IsHexDigit

func IsHexDigit(b byte) bool

func IsOctalDigit

func IsOctalDigit(b byte) bool

func IsRegular

func IsRegular(b byte) bool

Is the passed byte a regular PDF character?

func IsWhiteSpace

func IsWhiteSpace(b byte) bool

Is the passed byte PDF white space?

func NormalStringSerializer

func NormalStringSerializer(s String, w Writer)

func OpenFile

func OpenFile(filename string, mode int) (result *file, exists bool, err error)

OpenFile() construct a File object from either a new or a pre-existing filename.

func PDFDocEncoding

func PDFDocEncoding(s []rune) ([]byte, bool)

func ParseHexDigit

func ParseHexDigit(b byte) byte

func ParseOctalDigit

func ParseOctalDigit(b byte) byte

func ReadLine

func ReadLine(r io.ByteScanner) (result string, err error)

ReadLine() reads a line from a PDF file interpreting end-of-line characters according to the PDF specification. In contexts where you would be likely to use pdf.ReadLine() are where the line consists of ASCII characters. Therefore ReadLine() returns a string rather than a []byte.

func RegisterFilterFactoryFactory

func RegisterFilterFactoryFactory(name string, sfff func(ProtectedDictionary) StreamFilterFactory)

func StandardFontToName

func StandardFontToName(font StandardFont) (result string)

Types

type Array

type Array interface {
	ProtectedArray
	// Note that all objects added via Add(), PushFront(), or
	// Append() are Unprotect() before adding them so that owners
	// of the Array also own objects within it.
	Add(o Object)
	PushFront(o Object)
	Append(op ProtectedArray)
}

func NewArray

func NewArray() Array

Constructor for standard implementation of Array

type AsciiHexFilter

type AsciiHexFilter struct {
}

func (*AsciiHexFilter) DecodeParms

func (filter *AsciiHexFilter) DecodeParms(file ...File) Object

func (*AsciiHexFilter) Name

func (filter *AsciiHexFilter) Name() string

func (*AsciiHexFilter) NewDecoder

func (filter *AsciiHexFilter) NewDecoder(reader io.Reader) io.Reader

func (*AsciiHexFilter) NewEncoder

func (filter *AsciiHexFilter) NewEncoder(writer io.WriteCloser) io.WriteCloser

type AsciiHexReader

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

func (*AsciiHexReader) Read

func (ahr *AsciiHexReader) Read(buffer []byte) (n int, err error)

type AsciiHexWriter

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

func (*AsciiHexWriter) Close

func (ahw *AsciiHexWriter) Close() error

func (*AsciiHexWriter) Write

func (ahw *AsciiHexWriter) Write(buffer []byte) (n int, err error)

type Boolean

type Boolean interface {
	Object
	Value() bool
}

type BufferCloser

type BufferCloser struct {
	bytes.Buffer
}

func NewBufferCloser

func NewBufferCloser() *BufferCloser

func (*BufferCloser) Close

func (bc *BufferCloser) Close() error

type Dictionary

type Dictionary interface {
	ProtectedDictionary
	// Add() stores an object under the specified key.
	// The protection of the added Object is preserved.
	Add(key string, object Object)

	// Remove() removes the key and value stored under the
	// specified key.
	Remove(key string)
}

func NewDictionary

func NewDictionary() Dictionary

Constructor for Dictionary object

type Document

type Document struct {

	// DocumentInfo is initialized from a pre-existing documents
	// document info dictionary.  Otherwise it is initialized to
	// an empty dictionary.  It is not nil.
	DocumentInfo
	// contains filtered or unexported fields
}
Example
package main

import (
	"fmt"
	"github.com/mawicks/PDFiG/pdf"
	"os"
)

func main() {
	doc := pdf.OpenDocument("/tmp/test-document.pdf", os.O_RDWR|os.O_CREATE)
	doc.SetAuthor("Mark Wicks")
	doc.SetTitle("Test Document")

	// Page 1
	page := doc.NewPage()
	f1 := pdf.NewStandardFont(pdf.Helvetica)
	name := page.AddFont(f1)
	fmt.Fprintf(page, "BT /%s 24 Tf 250 528 Td (Hello World!) Tj ET", name)

	// Page 2
	page = doc.NewPage()
	fmt.Fprintf(page, "0 0 m 612 792 l s ")
	fmt.Fprintf(page, "0 792 m 612 0 l s")

	// Page 3
	page = doc.NewPage()
	name = page.AddFont(f1)
	fmt.Fprintf(page, "BT /%s 24 Tf 250 528 Td (Goodbye World!) Tj ET", name)

	doc.Close()
}
Output:

func OpenDocument

func OpenDocument(filename string, mode int) *Document

OpenDocument() constructs a document object from either a new or a pre-existing filename.

func (*Document) Close

func (d *Document) Close()

func (*Document) NewPage

func (d *Document) NewPage() *Page

NewPage() returns a Page reference. A Page reference implements the io.writer interface which may be used to write raw PDF streams to the page's contents stream. Pages created with Document.NewPage() are closed by the next call to Document.NewPage() or the call to Document.Close().

func (*Document) Page

func (d *Document) Page(n uint) *ExistingPage

Page(n) returns the ExistingPage (which contains a PageDictionary and an Indirect object) associated with page "n" of the document. The first page is numbered 0. Any inheritable attributes found while descending the page tree are copied into the dictionary, so the dictionary may not exactly match the one in the file.

func (*Document) SetArtBox

func (d *Document) SetArtBox(llx, lly, urx, ury float64)

func (*Document) SetBleedBox

func (d *Document) SetBleedBox(llx, lly, urx, ury float64)

func (*Document) SetCropBox

func (d *Document) SetCropBox(llx, lly, urx, ury float64)

func (*Document) SetMediaBox

func (d *Document) SetMediaBox(llx, lly, urx, ury float64)

func (*Document) SetStreamFactory

func (d *Document) SetStreamFactory(sf *StreamFactory)

SetStreamFactory() sets the StreamFactory used by the document for constructing page stream. The client may call NewStreamFactory(), add filters, etc., and tell the document to use that factory. The default factory uses LZW encoded streams.

func (*Document) SetTrimBox

func (d *Document) SetTrimBox(llx, lly, urx, ury float64)

func (*Document) WriteObject

func (d *Document) WriteObject(object Object) Indirect

type DocumentInfo

type DocumentInfo struct {
	Dictionary
	// contains filtered or unexported fields
}

func NewDocumentInfo

func NewDocumentInfo() DocumentInfo

func (DocumentInfo) IsDirty

func (d DocumentInfo) IsDirty() bool

func (DocumentInfo) SetAuthor

func (d DocumentInfo) SetAuthor(s string)

func (DocumentInfo) SetCreator

func (d DocumentInfo) SetCreator(s string)

func (DocumentInfo) SetKeywords

func (d DocumentInfo) SetKeywords(s string)

func (DocumentInfo) SetProducer

func (d DocumentInfo) SetProducer(s string)

func (DocumentInfo) SetSubject

func (d DocumentInfo) SetSubject(s string)

func (DocumentInfo) SetTitle

func (d DocumentInfo) SetTitle(s string)

type ExistingPage

type ExistingPage struct {
	*PageDictionary
	// contains filtered or unexported fields
}

func (*ExistingPage) Rewrite

func (ep *ExistingPage) Rewrite()

type FalseBoolean

type FalseBoolean struct{}

func (FalseBoolean) Clone

func (b FalseBoolean) Clone() Object

func (FalseBoolean) Dereference

func (b FalseBoolean) Dereference() Object

func (FalseBoolean) Protect

func (b FalseBoolean) Protect() Object

func (FalseBoolean) Serialize

func (b FalseBoolean) Serialize(w Writer, file ...File)

func (FalseBoolean) Unprotect

func (b FalseBoolean) Unprotect() Object

func (FalseBoolean) Value

func (b FalseBoolean) Value() bool

type File

type File interface {
	// WriteObject() adds the passed object to the File.  The
	// returned indirect reference may be used for backward
	// references to the object.  A new object is created
	// either at a new index in the xref or at an old index
	// using a new generation.
	WriteObject(Object) Indirect

	// WriteObjectAt() adds the object to the File at the specified
	// location.  ObjectNumber may have been obtained by an
	// earlier call to ReserveObjectNumber(), or ObjectNumber may
	// be a pre-existing (finalized) object that is being
	// overwritten with a modified copy.
	WriteObjectAt(ObjectNumber, Object)

	// Indirect() returns an Indirect that can be used to refer
	// to ObjectNumber in this file.  If an Indirect already
	// exists for this ObjectNumber, that Indirect is returned.
	// Otherwise a new one is created. In either case, this should
	// not return nil, even for a mock File.
	Indirect(ObjectNumber) Indirect

	// Object() used ObjectNumber to retrieve a direct object that
	// has already been written to a PDF file.
	Object(ObjectNumber) (Object, error)

	// ReserveObjectNumber() reserves a position (ObjectNumber)
	// for the passed object in the File.
	ReserveObjectNumber(Indirect) ObjectNumber

	// Info() returns a copy of the Info dictionary.  Caller may
	// modify the copy and use SetInfo() to replace the file's
	// info dictionary
	Info() Dictionary

	// Catalog() returns a copy of the Info dictionary.  Caller
	// may modify the copy and use SetCatalog() to replace the
	// file's info dictionary
	Catalog() ProtectedDictionary

	// SetCatalog() sets the catalog dictionary
	SetCatalog(Dictionary)

	// SetInfo() sets the Info dictionary
	SetInfo(DocumentInfo)

	// Trailer() returns a copy of the current contents of the
	// trailer dictionary
	Trailer() ProtectedDictionary

	// DeleteObject() deletes the specified object from the file.
	// It must be an indirect object.
	DeleteObject(Indirect)

	// Close() writes the xref, trailer, etc., and closes the
	// underlying file.
	Close()

	// Closed() returns true if the file has been closed.
	Closed() bool
}
Example (Creation)
package main

import (
	"github.com/mawicks/PDFiG/pdf"
	"os"
)

func main() {
	f, _, _ := pdf.OpenFile("/tmp/test-file.pdf", os.O_RDWR|os.O_CREATE)

	o1 := pdf.NewIndirect()
	indirect1 := f.WriteObject(o1)
	o1.Write(pdf.NewNumeric(3.14))

	indirect2 := f.WriteObject(pdf.NewNumeric(2.718))

	f.WriteObject(pdf.NewName("foo"))

	// Delete the *indirect reference* to the 3.14 numeric
	f.DeleteObject(indirect1)
	f.WriteObject(pdf.NewNumeric(3))

	// Delete the 2.718 numeric object itself
	f.DeleteObject(indirect2)

	p := pdf.NewPageFactory().New(f)
	p.SetParent(indirect1)
	p.SetMediaBox(0, 0, 612, 792)
	p.Finish()

	catalog := pdf.NewDictionary()
	catalog.Add("Type", pdf.NewName("Catalog"))
	f.SetCatalog(catalog)

	f.Close()
}
Output:

Example (Modification)
package main

import (
	"github.com/mawicks/PDFiG/pdf"
	"os"
)

func main() {
	f, _, _ := pdf.OpenFile("/tmp/pre-existing-file.pdf", os.O_RDWR|os.O_CREATE)
	documentInfo := pdf.NewDocumentInfo()
	documentInfo.SetTitle("Rewritten Title")
	documentInfo.SetAuthor("Nobody")
	documentInfo.SetCreator("Nothing")

	f.SetInfo(documentInfo)

	f.Close()
}
Output:

func NewMockFile

func NewMockFile(obj uint32, gen uint16) File

Constructor for mockFile object

type FlateFilter

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

func (*FlateFilter) DecodeParms

func (filter *FlateFilter) DecodeParms(file ...File) Object

func (*FlateFilter) Name

func (filter *FlateFilter) Name() string

func (*FlateFilter) NewDecoder

func (filter *FlateFilter) NewDecoder(reader io.Reader) io.Reader

func (*FlateFilter) NewEncoder

func (filter *FlateFilter) NewEncoder(writer io.WriteCloser) io.WriteCloser

func (*FlateFilter) SetCompressionLevel

func (filter *FlateFilter) SetCompressionLevel(level int)

type FlateReader

type FlateReader struct {
	io.Reader
}

type FlateWriter

type FlateWriter struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

func (*FlateWriter) Close

func (fw *FlateWriter) Close() error

type Font

type Font interface {
	Indirect(f File) Indirect
}

func NewStandardFont

func NewStandardFont(font StandardFont) Font

type Indirect

type Indirect interface {
	ProtectedIndirect
	Write(o Object) Indirect
}

func NewIndirect

func NewIndirect(file ...File) Indirect

NewIndirect is the constructor for Indirect objects. For convenience, if the files to which this indirect object should be bound are known at construction time, they may be provided as optional arguments. Instead of providing these at construction, the client may call Indirect.ObjectNumber() after construction.

type IntNumeric

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

IntNumeric implements Numeric

func (*IntNumeric) Clone

func (n *IntNumeric) Clone() Object

func (*IntNumeric) Dereference

func (n *IntNumeric) Dereference() Object

func (*IntNumeric) Protect

func (n *IntNumeric) Protect() Object

Numerics are always immutable so the return value of Protect() can safely be cast back to Numeric or IntNumeric

func (*IntNumeric) Serialize

func (n *IntNumeric) Serialize(w Writer, file ...File)

func (*IntNumeric) Unprotect

func (n *IntNumeric) Unprotect() Object

Numerics are always immutable so the return value of Unprotect() can safely be cast back to Numeric or IntNumeric

func (*IntNumeric) Value

func (n *IntNumeric) Value() int

type LZWFilter

type LZWFilter struct {
}

func (LZWFilter) DecodeParms

func (filter LZWFilter) DecodeParms(file ...File) Object

func (LZWFilter) Name

func (filter LZWFilter) Name() string

func (LZWFilter) NewDecoder

func (filter LZWFilter) NewDecoder(reader io.Reader) io.Reader

func (LZWFilter) NewEncoder

func (filter LZWFilter) NewEncoder(writer io.WriteCloser) io.WriteCloser

type LZWReader

type LZWReader struct {
	io.Reader
}

type LZWWriter

type LZWWriter struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

func (*LZWWriter) Close

func (w *LZWWriter) Close() error

func (*LZWWriter) Write

func (w *LZWWriter) Write(buffer []byte) (n int, err error)

type Name

type Name interface {
	Object
	String() string
}

func NewName

func NewName(s string) Name

Constructor for standard Name implementation

type Null

type Null struct{}

PDF "Null" object Implements: pdf.Object

func (*Null) Clone

func (n *Null) Clone() Object

func (*Null) Dereference

func (n *Null) Dereference() Object

func (*Null) Protect

func (n *Null) Protect() Object

Null is an immutable singleton, so the return value of Protect() can safely be cast back to Null.

func (*Null) Serialize

func (n *Null) Serialize(w Writer, file ...File)

func (*Null) Unprotect

func (n *Null) Unprotect() Object

Protect and unprotected interfaces are the same for null. Simply return the instance. The return value can safely be cast back to Null.

type Numeric

type Numeric interface {
	Value() interface{}
	Object
}

PDF "Numeric" object Implements:

pdf.Object

type Object

type Object interface {
	// Clone() copies the full state of the object so that future
	// changes to the clone do not affect the original object and
	// vice-versa.  For immutable objects Clone() may return the
	// original reference.  However, for container objects, a
	// clone is a deep copy.  As such it can be a relatively
	// expensive operation on a large container.  Protect() and
	// Unprotect() are less expensive and achieve a similar
	// effect.  If an interface has a protected and an unprotected
	// version, the valued returned from Clone() is the
	// unprotected version.  The returned value from Clone() can
	// safely be cast to the unprotected version of the interface
	// type whose Clone() method was invoked.
	Clone() Object

	// If the target is an indirect reference, Dereference()
	// returns an object that is not an indirect reference.
	// Otherwise it returns the target.
	Dereference() Object

	// Most PDF Objects have two versions of interfaces: a
	// protected one and an unprotected one.  The protected
	// interface is used when a method returns an object but wants
	// to be certain that the client cannot alter the object.
	// Protect() returns a protected interface instance. The
	// protected interface implements a subset of the methods
	// available for the unprotected version of the interface.
	// The returned value can safely be cast to the documented
	// protected version of the interface whose Protect() method
	// was invoked.  Although semantically protection is deep
	// (i.e., protecting a container protects all objects within
	// the container), the implementation is relatively efficient.
	Protect() Object

	// Unprotect() returns an unprotected interface instance.
	// When invoked on a protected interface, the semantics are
	// essentially copy-on-write.  When invoked on an unprotected
	// interface, it is a no-op.  Unprotecting is shallow.  It
	// applies to the container itself and not to the objects
	// within the container.  To modify a protected object in an
	// unprotected container, the protected object must be
	// unprotected, modified, and (because the unprotected object
	// is a copy) rewritten to the container.  The returned Object
	// may be cast to the documented unprotected version of the
	// interface whose Unprotect() method was invoked.
	Unprotect() Object

	// Serialize() write a serial byte representation (as defined
	// by the PDF specification) of the object to the Writer.
	// Indirect references are resolved and numbered as if they
	// were being written to the optional File argument.  Having
	// separate arguments for Writer and File allows writing an
	// object to any Writer interface (e.g., stdout for debugging
	// or a string writer for internal formatting), but using the
	// indirect reference object numbers as if it were contained
	// in a specific PDF file.  Objects can be unserialized using
	// Parser.Scan().
	Serialize(Writer, ...File)
}

All PDF objects implement the pdf.Object inteface

func NewBoolean

func NewBoolean(v bool) Object

Constructor for "Boolean" object. Since TrueBoolean and BooleanFalse are empty structs, returning by value in NewBoolean and implementing methods with value targets should be efficient.

func NewIntNumeric

func NewIntNumeric(v int) Object

Constructors for Numeric object

func NewNull

func NewNull() Object

func NewNumeric

func NewNumeric(v float64) (result Object)

func NewRealNumeric

func NewRealNumeric(v float32) Object

type ObjectNumber

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

func NewObjectNumber

func NewObjectNumber(number uint32, generation uint16) ObjectNumber

type ObjectStringDecorator

type ObjectStringDecorator struct {
	Object
}

ObjectStringDecorator adds the String() method to Object; delegating all other methods to object.

func (ObjectStringDecorator) String

func (o ObjectStringDecorator) String(file ...File) string

type Page

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

func (*Page) AddFont

func (p *Page) AddFont(font Font) string

func (*Page) Finish

func (p *Page) Finish() Indirect

func (*Page) SetArtBox

func (p *Page) SetArtBox(llx, lly, urx, ury float64)

func (*Page) SetBleedBox

func (p *Page) SetBleedBox(llx, lly, urx, ury float64)

func (*Page) SetCropBox

func (p *Page) SetCropBox(llx, lly, urx, ury float64)

func (*Page) SetMediaBox

func (p *Page) SetMediaBox(llx, lly, urx, ury float64)

func (*Page) SetParent

func (p *Page) SetParent(i Indirect)

func (*Page) SetTrimBox

func (p *Page) SetTrimBox(llx, lly, urx, ury float64)

func (*Page) Write

func (p *Page) Write(b []byte) (int, error)

type PageDictionary

type PageDictionary struct {
	ProtectedDictionary
	// contains filtered or unexported fields
}

A PageDictionary wraps a Dictionary to simplify access and to limit the operations to those that are valid for a page dictionary. Since it delegates to ProtectedDictionary, clients can treat it as if it were a dictionary. It is assumed that the ProtectedDictionary member has the "dictionary" member as its underlying dictionary. Clients acess the ProtectedDictionary but internal methods manipulate the underlying dictionary.

func NewPageDictionary

func NewPageDictionary() *PageDictionary

func (*PageDictionary) AppendContents

func (pd *PageDictionary) AppendContents(is Indirect)

AppendContents() appends the passed indirect reference (which must reference a stream) onto the page contents. The client is responsible for ensuring the indirect reference is associated with a stream object.

func (*PageDictionary) PrependContents

func (pd *PageDictionary) PrependContents(is Indirect)

PrependContents() prepends the passed indirect reference (which must reference a stream) in front of the page contents. The client is responsible for ensuring the indirect reference is associated with a stream object.

func (*PageDictionary) Reader

func (pd *PageDictionary) Reader() io.Reader

Return an io.Reader that will read the page's contents. Stream filters are applied and segments from multi-segment streams are concatenated.

func (*PageDictionary) SetArtBox

func (pd *PageDictionary) SetArtBox(llx, lly, urx, ury float64)

func (*PageDictionary) SetBleedBox

func (pd *PageDictionary) SetBleedBox(llx, lly, urx, ury float64)

func (*PageDictionary) SetContents

func (pd *PageDictionary) SetContents(is Indirect)

SetContents() sets the Contents value in the page dictionary to the passed indirect reference. The client is responsible for ensuring that the indirect reference is associated with a stream or possibly with an array of stream references.

func (*PageDictionary) SetCropBox

func (pd *PageDictionary) SetCropBox(llx, lly, urx, ury float64)

func (*PageDictionary) SetMediaBox

func (pd *PageDictionary) SetMediaBox(llx, lly, urx, ury float64)

func (*PageDictionary) SetParent

func (pd *PageDictionary) SetParent(ip Indirect)

SetParent() sets the Parent value in the page dictionary to the passed indirect reference. The client is responsible for ensuring that the indirect reference is a valid page dictionary or pages node reference.

func (*PageDictionary) SetResources

func (pd *PageDictionary) SetResources(ir Indirect)

SetResources() sets the Resources value in the page dictionary to the passed indirect reference. The client is responsible for ensuring that the indirect reference is a valid Resource dictionary.

func (*PageDictionary) SetTrimBox

func (pd *PageDictionary) SetTrimBox(llx, lly, urx, ury float64)

func (*PageDictionary) Write

func (pd *PageDictionary) Write(id Indirect) Indirect

type PageFactory

type PageFactory struct {
	*StreamFactory
}

func NewPageFactory

func NewPageFactory() *PageFactory

func (*PageFactory) New

func (pf *PageFactory) New(file ...File) *Page

func (*PageFactory) SetStreamFactory

func (pf *PageFactory) SetStreamFactory(sf *StreamFactory)

type Parser

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

func NewParser

func NewParser(scanner Scanner) *Parser

NewParser constructs a new parser from the passed Scanner. Typically Scanner will be the pdf.File's underlying os.File, but this is not strictly necessary.

func (*Parser) GetContext

func (p *Parser) GetContext() []byte

func (*Parser) Scan

func (p *Parser) Scan(file ...File) (o Object, err error)

Scan() parses an arbitrary object. If successful, the object is returned. If not, err is set and context contains the input bytes that preceeded the error. The optional File argument, of which there should be no more than one, indicates the pdf.File to use to resolve indirect object references (e.g., "25 0 R"). If no File is supplied, the input stream may not contain any indirect object references.

func (*Parser) ScanIndirect

func (p *Parser) ScanIndirect(objectNumber ObjectNumber, file ...File) (object Object, err error)

ScanIndirect() parses an indirect object including the "%d %d obj" header and "endobj" trailer. If successful the object is returned. It returns an error if the object number and generation do not match the passed ObjectNumber. The optional File argument is as described in Parser.Scan().

type ProtectString

type ProtectString interface {
	Object
	Bytes() []byte
}

PDF "String" object Implements:

pdf.Object

type ProtectedArray

type ProtectedArray interface {
	Object
	Size() int
	At(i int) Object
}

type ProtectedDictionary

type ProtectedDictionary interface {
	Object // A Dictionary must implement the Object interface.

	// Get() returns the object stored under the specified key.
	// or nil if the key doesn't exist.
	Get(key string) Object

	// GetArray() attempts to retrieve the dictionary entry as an
	// ProtectedArray, dereferencing as necessary.  It returns nil
	// if the entry doesn't exist or isn't a ProtectedArray.
	// ProtectedArray is a subset of the Array interface.  The
	// returned ProtectedArray may or may not implement the full
	// Array interface.
	GetArray(key string) ProtectedArray

	// GetBoolean() attempts to retrieve the dictionary entry as a
	// Boolean, dereferencing as necessary.  The second boolean
	// return value indicates whether the entry exists and is a
	// boolean.  If so, the first return value is the value of the
	// Boolean.
	GetBoolean(key string) (bool, bool)

	// GetDictionary() attempts to retrieve the dictionary entry
	// as a ProtectedDictionary, dereferencing as necessary.  It
	// returns nil if the entry doesn't exist or isn't a
	// ProtectedDictionary.  ProtectedDictionary is a subset of
	// the Dictionary interface. The returned ProtectedDictionary
	// may or may not implement the full Dictionary interface.
	GetDictionary(key string) ProtectedDictionary

	// GetIndirect() attempts to retrieve the dictionary entry as
	// a ProtectedIndirect object (no dereferencing is attempted).
	// The return value is nil if the entry doesn't exist or isn't
	// a ProtectedIndirect.  ProtectedIndirect is a subset of the
	// Indirect interface.  The returned ProtectedIndirect may or
	// may not implement the full Indirect interface.
	GetIndirect(key string) ProtectedIndirect

	// GetInt() attempts to retrieve the dictionary entry as an
	// integer, dereferencing as necessary.  The boolean return
	// value indicates whether the entry exists and is an Int.  If
	// so, the returned int represents the value of the integer.
	GetInt(key string) (int, bool)

	// GetName() attempts to retrieve the dictionary entry as a
	// Name, dereferencing as necessary.  The string value of the
	// name is returned.  The boolean return value indicates
	// whether the entry exists and is a name.  If so, the
	// returned string is the name, expressed as a string.
	GetName(key string) (string, bool)

	// GetReal() attempts to retrieve the dictionary entry as a
	// real, dereferencing as necessary.  The boolean return value
	// indicates whether the entry exists and is a Real.  If so,
	// the returned float32 is the value of the Real.
	GetReal(key string) (float32, bool)

	// GetStream() attempts to retrieve the dictionary entry as a
	// ProtectedStream, dereferencing as necessary.  It returns
	// nil if the entry doesn't exist or isn't a ProtectedStream.
	// ProtectedStream is a subset of the Stream interface.  The
	// return value may or may not implement the full Stream
	// interface.
	GetStream(key string) ProtectedStream

	// GetString() attempts to retrieve the dictionary entry as a
	// string, dereferencing as necessary.  The boolean return
	// value indicates whether the entry exists and is a String.
	// If so, the returned slice represents the byte sequence
	// represented by the string.
	GetString(key string) ([]byte, bool)

	// CheckNameValue() returns true if the value associated with
	// the key is a name represented by the expected string (after
	// applying name decoding).
	CheckNameValue(key string, expected string, file ...File) bool

	// Size() returns the number of key-value pairs
	Size() int

	// Keys() returns a slice of strings representing the
	// names in the dictionary
	Keys() []string
}

type ProtectedIndirect

type ProtectedIndirect interface {
	Object
	ObjectNumber(f File) ObjectNumber
	BoundToFile(f File) bool
}

type ProtectedStream

type ProtectedStream interface {
	Object
	Reader() (result io.Reader)
}

type RealNumeric

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

RealNumeric implements Numeric

func (*RealNumeric) Clone

func (n *RealNumeric) Clone() Object

func (*RealNumeric) Dereference

func (n *RealNumeric) Dereference() Object

func (*RealNumeric) Protect

func (n *RealNumeric) Protect() Object

Numerics are always immutable so the return value of Protect() can safely be cast back to Numeric or RealNumeric.

func (*RealNumeric) Serialize

func (n *RealNumeric) Serialize(w Writer, file ...File)

func (*RealNumeric) Unprotect

func (n *RealNumeric) Unprotect() Object

Numerics are immutable so the return value of Unprotect() can safely be cast back to Numeric or RealNumeric.

func (*RealNumeric) Value

func (n *RealNumeric) Value() float32

type Rectangle

type Rectangle struct {
	ProtectedArray
}

func NewRectangle

func NewRectangle(llx, lly, urx, ury float64) *Rectangle

type Scanner

type Scanner interface {
	io.ByteScanner
	io.Reader
}

type StandardFont

type StandardFont uint8
const (
	TimesRoman StandardFont = iota
	Helvetica
	Courier
	Symbol
	TimesBold
	HelveticaBold
	CourierBold
	ZapfDingbats
	TimesItalic
	HelveticaOblique
	CourierOblique
	TimesBoldItalic
	HelveticaBoldOblique
	CourierBoldOblique
)

type Stream

type Stream interface {
	ProtectedStream
	io.Writer
	AddFilter(filter StreamFilterFactory)
	Remove(key string)
}

func NewStream

func NewStream() Stream

Constructor for standard implementation of Stream.

func NewStreamFromContents

func NewStreamFromContents(dictionary Dictionary, b []byte, filterList *list.List) Stream

type StreamFactory

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

StreamFactory is used to generate Streams with client-specified options. Options are set in the StreamFactory and all Streams generated by the factory will have those specified options.

func NewStreamFactory

func NewStreamFactory() *StreamFactory

func (*StreamFactory) AddFilter

func (sf *StreamFactory) AddFilter(sff StreamFilterFactory)

func (*StreamFactory) New

func (sf *StreamFactory) New() Stream

type StreamFilterFactory

type StreamFilterFactory interface {
	Name() string
	NewEncoder(io.WriteCloser) io.WriteCloser
	NewDecoder(io.Reader) io.Reader
	DecodeParms(file ...File) Object
}

type String

type String interface {
	ProtectString
	SetSerializer(func(String, Writer))
}

func NewBinaryString

func NewBinaryString(s []byte) String

func NewTextString

func NewTextString(s string) String

Constructor for Name object

type TrueBoolean

type TrueBoolean struct{}

func (TrueBoolean) Clone

func (b TrueBoolean) Clone() Object

func (TrueBoolean) Dereference

func (b TrueBoolean) Dereference() Object

func (TrueBoolean) Protect

func (b TrueBoolean) Protect() Object

func (TrueBoolean) Serialize

func (b TrueBoolean) Serialize(w Writer, file ...File)

func (TrueBoolean) Unprotect

func (b TrueBoolean) Unprotect() Object

func (TrueBoolean) Value

func (b TrueBoolean) Value() bool

type Writer

type Writer interface {
	Write(p []byte) (nn int, err error)
	WriteByte(c byte) error
	WriteRune(r rune) (size int, err error)
	WriteString(s string) (int, error)
}

Jump to

Keyboard shortcuts

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