diff --git a/pdf/core/primitives.go b/pdf/core/primitives.go index 6e530c2b..3278e924 100644 --- a/pdf/core/primitives.go +++ b/pdf/core/primitives.go @@ -296,6 +296,7 @@ func (str *PdfObjectString) DefaultWriteString() string { return output.String() } +// String returns a string representation of `name`. func (name *PdfObjectName) String() string { return string(*name) } @@ -581,6 +582,12 @@ func (d *PdfObjectDictionary) Keys() []PdfObjectName { return d.keys } +// Clear resets the dictionary to an empty state. +func (d *PdfObjectDictionary) Clear() { + d.keys = []PdfObjectName{} + d.dict = map[PdfObjectName]PdfObject{} +} + // Remove removes an element specified by key. func (d *PdfObjectDictionary) Remove(key PdfObjectName) { idx := -1 diff --git a/pdf/model/page.go b/pdf/model/page.go index b5184f5d..01cc5136 100644 --- a/pdf/model/page.go +++ b/pdf/model/page.go @@ -443,6 +443,7 @@ func (this *PdfPage) getResources() (*PdfPageResources, error) { // Convert the Page to a PDF object dictionary. func (this *PdfPage) GetPageDict() *PdfObjectDictionary { p := this.pageDict + p.Clear() p.Set("Type", MakeName("Page")) p.Set("Parent", this.Parent)