diff --git a/App/Processor/DocInfoImporter.cs b/App/Processor/DocInfoImporter.cs index f497b52..6cacb17 100644 --- a/App/Processor/DocInfoImporter.cs +++ b/App/Processor/DocInfoImporter.cs @@ -48,10 +48,10 @@ namespace PDFPatcher.Processor _options = options; } - internal DocInfoImporter(ImporterOptions importerOptions, PdfReader pdf, PatcherOptions patcherOptions, BookmarkRootElement bookmarkRoot) { + internal DocInfoImporter(ImporterOptions importerOptions, PdfReader pdf, PatcherOptions patcherOptions, PdfInfoXmlDocument infoDoc) { var v = patcherOptions.ViewerPreferences; var o = new ExporterOptions() { - ExportBookmarks = bookmarkRoot == null + ExportBookmarks = infoDoc.BookmarkRoot == null && (v.RemoveZoomRate || v.CollapseBookmark != BookmarkStatus.AsIs || v.ForceInternalLink @@ -70,31 +70,10 @@ namespace PDFPatcher.Processor o.UnitConverter.Unit = Constants.Units.Point; var exp = new DocInfoExporter(pdf, o); Tracker.SetProgressGoal(exp.EstimateWorkload()); - using (var ms = new MemoryStream()) { - using (var w = XmlWriter.Create(ms, new XmlWriterSettings { CheckCharacters = false })) { - w.WriteStartElement(Constants.PdfInfo); - w.WriteAttributeString(Constants.Info.ProductVersion, Constants.InfoDocVersion); - exp.ExportDocument(w); - if (bookmarkRoot != null) { - var bookmark = bookmarkRoot.CreateNavigator(); - bookmark.WriteSubtree(w); - //if (bookmark.MoveToFirstChild()) { - // bookmark.WriteSubtree(w); - //} - //while (bookmark.MoveToNext()) { - // bookmark.WriteSubtree(w); - //} - } - w.WriteEndElement(); - } - ms.Flush(); - ms.Position = 0; - var x = new PdfInfoXmlDocument(); - x.Load(ms); - _options = importerOptions; - _unitFactor = 1; - _infoDoc = x; - } + + _options = importerOptions; + _unitFactor = 1; + _infoDoc = infoDoc; } internal static float GetUnitFactor(XmlElement root) { diff --git a/App/Processor/Worker.cs b/App/Processor/Worker.cs index 738e7a0..c473abb 100644 --- a/App/Processor/Worker.cs +++ b/App/Processor/Worker.cs @@ -268,7 +268,7 @@ namespace PDFPatcher.Processor var xInfoDoc = infoDoc as PdfInfoXmlDocument; var docPath = infoDoc as string; if (xInfoDoc != null) { - import = new DocInfoImporter(options, pdf, pdfSettings, xInfoDoc.BookmarkRoot); + import = new DocInfoImporter(options, pdf, pdfSettings, xInfoDoc); } else if (String.IsNullOrEmpty(docPath)) { Tracker.TraceMessage("没有指定信息文件,将按程序界面的设置执行补丁。");