2016-09-09 15:02:52 +00:00
|
|
|
/*
|
|
|
|
* 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 (
|
2019-05-16 23:08:40 +03:00
|
|
|
"github.com/unidoc/unipdf/v3/common"
|
2019-05-16 23:44:51 +03:00
|
|
|
"github.com/unidoc/unipdf/v3/core"
|
2016-09-09 15:02:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func getUniDocVersion() string {
|
|
|
|
return common.Version
|
|
|
|
}
|
|
|
|
|
2018-09-29 02:21:56 +00:00
|
|
|
// NewReaderForText makes a new PdfReader for an input PDF content string. For use in testing.
|
|
|
|
func NewReaderForText(txt string) *PdfReader {
|
|
|
|
// Create the parser, loads the cross reference table and trailer.
|
2018-10-23 11:43:02 +00:00
|
|
|
return &PdfReader{
|
2019-04-14 22:22:41 +00:00
|
|
|
traversed: map[core.PdfObject]struct{}{},
|
2018-10-23 11:43:02 +00:00
|
|
|
modelManager: newModelManager(),
|
|
|
|
parser: core.NewParserFromString(txt),
|
|
|
|
}
|
2018-09-29 02:21:56 +00:00
|
|
|
}
|
|
|
|
|
2017-04-19 12:05:20 +00:00
|
|
|
// Handy function for debugging in development.
|
2018-07-25 12:00:49 +10:00
|
|
|
func debugObject(obj core.PdfObject) {
|
2017-04-19 12:05:20 +00:00
|
|
|
common.Log.Debug("obj: %T %s", obj, obj.String())
|
|
|
|
|
2018-07-25 12:00:49 +10:00
|
|
|
if stream, is := obj.(*core.PdfObjectStream); is {
|
|
|
|
decoded, err := core.DecodeStream(stream)
|
2017-04-19 12:05:20 +00:00
|
|
|
if err != nil {
|
|
|
|
common.Log.Debug("Error: %v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
common.Log.Debug("Decoded: %s", decoded)
|
2018-07-25 12:00:49 +10:00
|
|
|
} else if indObj, is := obj.(*core.PdfIndirectObject); is {
|
2017-04-19 12:05:20 +00:00
|
|
|
common.Log.Debug("%T %v", indObj.PdfObject, indObj.PdfObject)
|
|
|
|
common.Log.Debug("%s", indObj.PdfObject.String())
|
|
|
|
}
|
|
|
|
}
|