public IDocumentPage DuplicatePage(Guid pageGuid) { CheckOpen(); if (!Pages.Contains(pageGuid)) { throw new ArgumentException("pageGuid"); } Serializer writer = new Serializer(_workingDirectoryGuid, Guid.Empty, _workingImagesDirectory); if (_documentData.DocumentType == DocumentType.Library) { CustomObjectPage sourcePage = Pages[pageGuid] as CustomObjectPage; writer.AddCustomObjectPage(sourcePage); } else { StandardPage sourcePage = Pages[pageGuid] as StandardPage; writer.AddStandardPage(sourcePage); } IDocumentPage newPage = null; using (Stream stream = writer.WriteToStream()) { IObjectContainer container = AddPages(stream); if (_documentData.DocumentType == DocumentType.Library) { if (container.CustomObjectPageList.Count > 0) { newPage = container.CustomObjectPageList[0]; } } else { if (container.StandardPageList.Count > 0) { newPage = container.StandardPageList[0]; } } } return(newPage); }