unipdf/pdf/model/utils.go
2018-09-29 02:21:56 +00:00

46 lines
1.2 KiB
Go

/*
* This file is subject to the terms and conditions defined in
* file 'LICENSE.md', which is part of this source code package.
*/
package model
import (
"github.com/unidoc/unidoc/common"
"github.com/unidoc/unidoc/pdf/core"
)
func getUniDocVersion() string {
return common.Version
}
// NewReaderForText makes a new PdfReader for an input PDF content string. For use in testing.
func NewReaderForText(txt string) *PdfReader {
r := &PdfReader{}
r.traversed = map[core.PdfObject]bool{}
r.modelManager = newModelManager()
// Create the parser, loads the cross reference table and trailer.
parser := core.NewParserFromString(txt)
r.parser = parser
return r
}
// Handy function for debugging in development.
func debugObject(obj core.PdfObject) {
common.Log.Debug("obj: %T %s", obj, obj.String())
if stream, is := obj.(*core.PdfObjectStream); is {
decoded, err := core.DecodeStream(stream)
if err != nil {
common.Log.Debug("Error: %v", err)
return
}
common.Log.Debug("Decoded: %s", decoded)
} else if indObj, is := obj.(*core.PdfIndirectObject); is {
common.Log.Debug("%T %v", indObj.PdfObject, indObj.PdfObject)
common.Log.Debug("%s", indObj.PdfObject.String())
}
}