/* ----------------------------------------------------------------- */ /// /// SaveOne /// /// <summary> /// Saves the specified page. /// </summary> /// /* ----------------------------------------------------------------- */ private void SaveOne(PdfReader reader, int pagenum, string dest) { var kv = WriterFactory.Create(dest, Metadata, UseSmartCopy, IO); kv.Value.Set(Encryption); kv.Key.Open(); kv.Value.AddPage(kv.Value.GetImportedPage(reader, pagenum)); kv.Key.Close(); kv.Value.Close(); }
/* ----------------------------------------------------------------- */ /// /// Finalize /// /// <summary> /// Adds some additional metadata to the merged document. /// </summary> /// /* ----------------------------------------------------------------- */ private void Finalize(string src, string dest) { using (var reader = ReaderFactory.Create(src)) using (var writer = WriterFactory.Create(dest, reader, IO)) { writer.Writer.Outlines = Bookmarks; writer.Set(Metadata, reader.Info); writer.Writer.Set(Encryption); if (Metadata.Version.Minor >= 5) { writer.SetFullCompression(); } } }
/* ----------------------------------------------------------------- */ /// /// Merge /// /// <summary> /// Merges pages and save the document to the specified path. /// </summary> /// /// <remarks> /// 注釈等を含めて完全にページ内容をコピーするため、いったん /// PdfCopy クラスを用いて全ページを結合します。セキュリティ設定や /// 文書プロパティ等の情報は生成された PDF に対して付加します。 /// </remarks> /// /* ----------------------------------------------------------------- */ private void Merge(string dest) { var kv = WriterFactory.Create(dest, Metadata, UseSmartCopy, IO); kv.Key.Open(); Bookmarks.Clear(); foreach (var page in Pages) { AddPage(page, kv.Value); } kv.Value.Set(Attachments); kv.Key.Close(); kv.Value.Close(); }