/* Antenna House PDF Tool API V8.0 .Net Interface sample program 概要:DeviceN Color Copyright 2025 Antenna House,Inc. */ using System; using PdfTkNet; if (args.Length < 2) { Console.WriteLine("usage: DeviceNColor.exe in-pdf-file out-pdf-file"); return; } try { using (PtlParamInput input = new PtlParamInput(args[0])) using (PtlParamOutput output = new PtlParamOutput(args[1])) using (PtlPDFDocument doc = new PtlPDFDocument()) { // PDFファイルをロードします。 doc.load(input); int comp = (int)(PtlColorSpaceDeviceN.DEVICEN_COMP.COMP_Cyan | PtlColorSpaceDeviceN.DEVICEN_COMP.COMP_Magenta | PtlColorSpaceDeviceN.DEVICEN_COMP.COMP_Yellow | PtlColorSpaceDeviceN.DEVICEN_COMP.COMP_Black); // ページコンテナの取得 using (PtlPages pages = doc.getPages()) using (PtlPage page = pages.get(0)) using (PtlContent content = page.getContent()) using (PtlColorSpaceSeparation csSep1 = new PtlColorSpaceSeparation("SEP1", 0.7f, 0.8f, 1.0f, 0.9f)) using (PtlColorSpaceSeparation csSep2 = new PtlColorSpaceSeparation("SEP2", 0.3f, 0.5f, 0.6f, 0.4f)) using (PtlColorSpaceSeparation csSep3 = new PtlColorSpaceSeparation("SEP3", 0.4f, 0.3f, 0.5f, 0.2f)) using (PtlColorSpaceSeparation csSep4 = new PtlColorSpaceSeparation("SEP4", 0.6f, 0.7f, 0.2f, 0.1f)) using (PtlColorSpaceDeviceN csDeviceN = new PtlColorSpaceDeviceN(comp, csSep1, csSep2, csSep3, csSep4)) using (PtlColorDeviceN colorDeviceN = new PtlColorDeviceN(csDeviceN, 0.4f, 0.7f, 0.5f, 0.2f, 0.3f, 0.4f, 0.5f, 0.2f)) using (PtlParamDrawShape shape = new PtlParamDrawShape()) using (PtlRect rect = new PtlRect(0.0f, 0.0f, 100.0f, 100.0f)) { shape.setFillColor(colorDeviceN); shape.setLineColor(colorDeviceN); //円形を描画 content.drawCircle(rect, shape); doc.save(output); } } } catch (PtlException pex) { Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP()); pex.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { Console.WriteLine("-- 完了 --"); }