diff --git a/src/UglyToad.PdfPig/Writer/PdfMerger.cs b/src/UglyToad.PdfPig/Writer/PdfMerger.cs index ae6c0cb4..7cf3ae4a 100644 --- a/src/UglyToad.PdfPig/Writer/PdfMerger.cs +++ b/src/UglyToad.PdfPig/Writer/PdfMerger.cs @@ -221,29 +221,15 @@ pageReferences.Add(new IndirectReferenceToken(newEntry)); } - var contentDictionary = new Dictionary + var pagesDictionary = new DictionaryToken(new Dictionary { { NameToken.Type, NameToken.Pages }, { NameToken.Kids, new ArrayToken(pageReferences) }, { NameToken.Count, new NumericToken(pageReferences.Count) }, { NameToken.Parent, treeParentReference } - }; + }); - // Copy page tree properties, if there any that doesn't conflict with the new ones - foreach(var set in treeNode.NodeDictionary.Data) - { - var nameToken = NameToken.Create(set.Key); - - // We don't want to override any value - if (contentDictionary.ContainsKey(nameToken)) - continue; - - contentDictionary.Add(NameToken.Create(nameToken), CopyToken(set.Value, tokenScanner)); - } - - var pagesToken = new DictionaryToken(contentDictionary); - - return Context.WriteObject(Memory, pagesToken, currentNodeReserved); + return Context.WriteObject(Memory, pagesDictionary, currentNodeReserved); } private ObjectToken CopyPageNode(PageTreeNode pageNode, IndirectReferenceToken parentPagesObject, IPdfTokenScanner tokenScanner)