Clear page dictionary prior to building. Add dictionary clear method

This commit is contained in:
Gunnsteinn Hall 2018-08-07 20:51:15 +00:00
parent 9c55596e2d
commit 01cd086550
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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)