/* Antenna House PDF Tool API V7.0 .NET Interface sample program 概要:PDFファイルの結合 Copyright 2013-2021 Antenna House, Inc. */ using System; using PdfTkNet; namespace AppendPages { class Program { static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("usage: AppendPages.exe input-pdf output-pdf append-pdf-file"); return; } try { using (PtlParamInput inputFile = new PtlParamInput(args[0])) using (PtlParamOutput outputFile = new PtlParamOutput(args[1])) using (PtlParamInput appendfile = new PtlParamInput(args[2])) using (PtlPDFDocument doc = new PtlPDFDocument()) using (PtlPDFDocument doc_app = new PtlPDFDocument()) { // PDFファイルをロードします。 doc.load(inputFile); using (PtlPages pages = doc.getPages()) //ページコンテナの取得 { // 追加するPDFファイルをロードします。 doc_app.load(appendfile); // ページの追加(1P目から全頁) OPTION_COPY_OUTLINES = 0x00000004 /* ページ挿入時にあわせてしおりをコピーします。他PDFのページ挿入時に有効となります。 */ pages.append(doc_app, 0, (int)PtlPages.NUM_PAGES.PAGE_ALL, PtlPages.INSERT_OPTION.OPTION_COPY_OUTLINES); } // ファイルに保存します。 doc.save(outputFile); } } catch (PtlException pex) { Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP()); pex.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("-- 完了 --"); } } } }