mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-17 04:41:14 +08:00
-修复编辑器指定页面标签无法保存到PDF文档的问题
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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("没有指定信息文件,将按程序界面的设置执行补丁。");
|
||||
|
||||
Reference in New Issue
Block a user