forked from cucy/unipdf1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
42 lines (36 loc) · 1.16 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* 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/unipdf/v3/common"
"github.com/unidoc/unipdf/v3/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 {
// Create the parser, loads the cross reference table and trailer.
return &PdfReader{
traversed: map[core.PdfObject]struct{}{},
modelManager: newModelManager(),
parser: core.NewParserFromString(txt),
}
}
// 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())
}
}