Doc fixes

This commit is contained in:
Gunnsteinn Hall 2018-07-14 03:15:54 +00:00
parent dcf9262bf6
commit 0edf3b11bf

View File

@ -9,23 +9,24 @@ import (
. "github.com/unidoc/unidoc/pdf/core"
)
// A PDFModel is a higher level PDF construct which can be collapsed into a PDF primitive.
// Each PDFModel has an underlying Primitive and vice versa.
// Copies can be made, but care must be taken to do it properly.
// PdfModel represents a high level PDF type which can be collapsed into a PDF primitive (typically a dictionary
// contained within an indirect object).
type PdfModel interface {
ToPdfObject() PdfObject
GetContainingPdfObject() PdfObject
}
// The model manager is used to cache Primitive <-> Model mappings where needed.
// In many cases only Model -> Primitive mapping is needed and only a reference to the Primitive
// is stored in the Model. In some cases, the Model needs to be found from the Primitive,
// modelManager is used to cache PdfObject <-> Model mappings where needed.
// In many cases only Model -> PdfObject mapping is needed and only a reference to the PdfObject
// is stored in the Model. In some cases, the Model needs to be found given the PdfObject,
// and that is where the modelManager can be used (in both directions).
//
// Note that it is not always used, the Primitive <-> Model mapping needs to be registered
// for each time it is used. Thus, it is only used for special cases, commonly where the same
// object is used by two higher level objects. (Example PDF Widgets owned by both Page Annotations,
// and the interactive form - AcroForm).
// object is used by two higher level objects.
//
// Example use case: PDF Annotation Widgets can be referenced by both Page Annotations, and the interactive
// form - AcroForm. With the cache, can check if already loaded and get the underlying model without duplication.
type modelManager struct {
primitiveCache map[PdfModel]PdfObject
modelCache map[PdfObject]PdfModel