/* Antenna House PDF Tool API V7.0 .NET Interface sample program 概要:PDF/A-1b,PDF/A-2bへの変換 Copyright 2021 Antenna House,Inc. */ using System; using PdfTkNet; namespace FixUpPDFA { class FixUpPDFA { static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("usage: FixUpPDFA.exe in-pdf-file out-pdf-file"); Console.WriteLine("規格\n1 : PDF/A-1b 2 : PDF/A-1b"); return; } try { PtlPDFFixUp.PDFA_TYPE type; string desc = args[2]; switch (args[2]) { case "1": type = PtlPDFFixUp.PDFA_TYPE.PDFA_1B; desc = "PDF/A-1b"; break; case "2": type = PtlPDFFixUp.PDFA_TYPE.PDFA_2B; desc = "PDF/A-2b"; break; default: Console.WriteLine("usage: FixUpPDFA.exe in-pdf-file out-pdf-file"); Console.WriteLine("規格\n1 : PDF/A-1b 2 : PDF/A-1b"); return; } using (PtlParamInput inputFile = new PtlParamInput(args[0])) using (PtlParamOutput outputFile = new PtlParamOutput(args[1])) using (PtlPDFFixUp fix = new PtlPDFFixUp()) using (PtlParamInput iccpcmyk = new PtlParamInput(@"D:\Develop\AHPDFFixUp\icc\JapanColor2001Coated.icc")) using (PtlParamInput iccprgb = new PtlParamInput(@"D:\Develop\AHPDFFixUp\icc\sRGB2014.icc")) { fix.setSaveOption(PtlPDFFixUp.SAVE_OPTION.SAVE_RECONSTRUCT); //保存時のオプションを設定 fix.setICCProfileCMYK(iccpcmyk); //出力インテントのプロファイル(CMYK用) fix.setICCProfileRGB(iccprgb); //出力インテントのプロファイル(RGB用) // PDF/Aへの変換 bool bl = fix.fixUpPDFA(PtlPDFFixUp.PDFA_TYPE.PDFA_1B, inputFile); if (bl) { Console.WriteLine(desc + " への変換に成功しました。"); } else { Console.WriteLine(desc + " への変換に失敗しました。"); //変換エラーの内容を取得する using (PtlPDFFixUpErrors fxuperrs = fix.getErrors()) { int count = fxuperrs.getCount(); Console.WriteLine("エラー数 : " + count); for (int i = 0; i < count; i++) { using (PtlPDFFixUpError fxuperr = fxuperrs.get(i)) { Console.WriteLine(fxuperr.getErrorCode() + " : " + fxuperr.getErrorMessageJP()); } } } } // PDF文書を保存 fix.save(outputFile); } Console.WriteLine("-- 完了 --"); } catch (PtlException pex) { Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP()); pex.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }