PDF Tool APIサンプル集:PDFフォームがあるPDFからXFDFの出力の例
フォームのあるPDFのパス、XFDFの出力先となるファイルパスを指定し
XFDFを出力するコンソールアプリケーションです。
概要
コマンドラインでの実行例
sample.exe c:\test\sampleSheet08.pdf c:\sav\out.xfdf
ダウンロード
出力結果イメージ

(この画像内でのXFDFファイルイメージは改行を入れ調整してます)
サンプルコード
/*
Antenna House PDF Tool API 7.0
C# Interface sample program
概要:PDFフォームがあるPDFからXFDFの出力
Copyright 2022 Antenna House,Inc.
*/
using System;
using PdfTkNet;
namespace sample08cs
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("PDF Tool API V7.0 C# サンプル");
// 入出力ファイル名の初期値を設定
string inFilePath = @"C:\test\sampleSheet08.pdf";
string outFilePath = @"C:\sav\outxfdf08.xfdf";
// 入力ファイル名
if (args.Length > 0)
{
inFilePath = args[0];
}
// 出力XFDFファイル名
if (args.Length > 1)
{
outFilePath = args[1];
}
try
{
using (PtlParamInput input = new PtlParamInput(inFilePath))
using (PtlParamOutput output = new PtlParamOutput(outFilePath))
using (PtlPDFDocument doc = new PtlPDFDocument())
{
// PDFファイルをロードします。
doc.load(input);
//フォームフィールドデータのXFDF文書へのエクスポート
doc.exportFormFieldsToXFDF(output);
Console.WriteLine("-- 完了 --");
}
}
catch (PtlException pex)
{
Console.WriteLine(pex.getErrorCode() + " : " + pex.getErrorMessageJP());
pex.Dispose();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

