Documentation
¶
Index ¶
- Constants
- type PdfReader
- func (pr *PdfReader) GetAllPageBoxes(k float64) (map[int]map[string]map[string]float64, error)
- func (pr *PdfReader) GetContent(pageno int) (string, error)
- func (pr *PdfReader) GetNumPages() (int, error)
- func (pr *PdfReader) GetPageBoxes(pageno int) (map[string]map[string]float64, error)
- func (pr *PdfReader) GetPageResources(pageno int) (*PdfValue, error)
- func (pr *PdfReader) GetPageRotation(pageno int) (*PdfValue, error)
- func (pr *PdfReader) ResolveObject(objSpec *PdfValue) (*PdfValue, error)
- type PdfValue
Constants ¶
const ( // PDFTypeNull means “no type” PDFTypeNull = iota // PDFTypeNumeric is a numeric type PDFTypeNumeric // PDFTypeToken is a name or something similar PDFTypeToken // PDFTypeHex is a hexadecimal encoded string such as <0012> PDFTypeHex // PDFTypeString is a string in parenthesis PDFTypeString // PDFTypeDictionary represents a Dictionary in double angle brackets << ... >>. The keys are strings and the values are PDF values PDFTypeDictionary // PDFTypeArray is an array [ ... ] PDFTypeArray // PDFTypeObjDec is a decimal (integer) object PDFTypeObjDec // PDFTypeObjRef is an indirect reference to an object such as 1 0 R PDFTypeObjRef // PDFTypeObject ... PDFTypeObject // PDFTypeStream is a slice of bytes representing a PDF stream PDFTypeStream // PDFTypeBoolean is either true or false PDFTypeBoolean // PDFTypeReal is a numeric with decimal places PDFTypeReal )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PdfReader ¶
type PdfReader struct {
SourceFile string
// contains filtered or unexported fields
}
A PdfReader reads a PDF file for importing
func NewPdfReader ¶
NewPdfReader opens a PDF file and returns a PdfReader
func NewPdfReaderFromStream ¶
func NewPdfReaderFromStream(rs io.ReadSeeker) (*PdfReader, error)
NewPdfReaderFromStream opens the io.ReadSeeker and returns a PdfReader object
func (*PdfReader) GetAllPageBoxes ¶
GetAllPageBoxes returns all pages boxes. k is a scaling factor (not yet implemented)
func (*PdfReader) GetContent ¶
GetContent returns the stream for the given page (i.e. PDF drawing instructions)
func (*PdfReader) GetNumPages ¶
GetNumPages returns the number of pages in the PDF file
func (*PdfReader) GetPageBoxes ¶
GetPageBoxes gets all page box data
func (*PdfReader) GetPageResources ¶
GetPageResources gets references to page resources for a given page number
func (*PdfReader) GetPageRotation ¶
GetPageRotation returns the page rotation for a page number
func (*PdfReader) ResolveObject ¶
ResolveObject returns the direct object referenced by objSpec. If objSpec is not an indirect reference (PDFTypeObjRef), it is returned unchanged.
Key improvements over the original:
- We DO NOT access pr.xref[objSpec.ID][objSpec.Gen] before verifying both map levels exist.
- We create the bufio.Reader *after* seeking the file to the correct offset.
- We preserve and restore the original file position even on errors where possible.
- We produce clearer, idiomatic error messages with %w wrapping.
type PdfValue ¶
type PdfValue struct {
Type int
String string
Token string
Int int
Real float64
Bool bool
Dictionary map[string]*PdfValue
Array []*PdfValue
ID int
NewID int
Gen int
Value *PdfValue
Stream *PdfValue
Bytes []byte
}
A PdfValue holds any data structure found within a PdF file. The used file is provided by the Type attribute