Class PdfForm
Documentize.PdfForm コンポーネントを表します。Flatten、Extract Forms Data に使用します。また、フィールド名の取得も可能です。
Documentize.PdfForm コンポーネントを表します。Flatten、Extract Forms Data に使用します。
また、フィールド名の取得も可能です。
public static class PdfForm継承
継承メンバー
- object.GetType(),
- object.MemberwiseClone(),
- object.ToString(),
- object.Equals(object?),
- object.Equals(object?, object?),
- object.ReferenceEquals(object?, object?),
- object.GetHashCode()
メソッド
Extract(ExtractFormDataToDsvOptions)
PDF ドキュメントからフォームデータを抽出します。
public static ResultContainer Extract(ExtractFormDataToDsvOptions options)パラメーター
optionsExtractFormDataToDsvOptions: 操作指示を含むオプション オブジェクト。
戻り値
ResultContainer : 操作の結果を含むオブジェクト。
使用例
フォームの値を CSV ファイルにエクスポートする例です。
// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions(',', true);
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_csv_file.csv"));
// Perform the process
PdfForm.Extract(options);フォームの値を TSV ファイルにエクスポートし、プロパティを設定する例です。
// Create ExtractFormDataToDsvOptions object to set instructions
var options = new ExtractFormDataToDsvOptions();
//Set Delimiter
options.Delimiter = '\t';
//Add Field Names to result
options.AddFieldName = true;
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_csv_file.tsv"));
// Perform the process
PdfForm.Extract(options);例外
オプションが設定されていない場合。
Flatten(FlattenFieldsOptions)
PDF ドキュメントのフィールドを Flatten します。
public static ResultContainer Flatten(FlattenFieldsOptions options)パラメーター
optionsFlattenFieldsOptions: 操作指示を含むオプション オブジェクト。
戻り値
ResultContainer : 操作の結果を含むオブジェクト。
使用例
PDF ファイルのフィールドを Flatten する例です。
// Create FlattenFieldsOptions object to set instructions
var options = new FlattenFieldsOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfForm.Flatten(options);最初のフィールドをスキップして PDF ファイルのフィールドを Flatten する例です。
// Get Fields Names
var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions("path_to_your_pdf_file.pdf"));
// Create FlattenFieldsOptions object to set instructions
var options = new FlattenFieldsOptions();
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Skip 1 field.
options.SkipFields.Add(fieldNames[0]);
// Perform the process
PdfForm.Flatten(options);例外
オプションが設定されていない場合。
GetNames(GetFieldNamesOptions)
PDF ドキュメント内のすべてのインタラクティブ フォーム フィールドの名前を取得します。
public static List<string> GetNames(GetFieldNamesOptions options)パラメーター
optionsGetFieldNamesOptions: 入力ソース(ファイル パスまたはストリーム)と操作指示を指定する Documentize.GetFieldNamesOptions のインスタンス。
戻り値
PDF ドキュメントで見つかったフィールド名を表す文字列のリスト。
使用例
最も簡潔なスタイルで PDF ファイルからフィールド名を取得する例です。
// Get field names
var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions("path_to_your_pdf_file.pdf"));PDF ファイルからフィールド名を取得する例です。
// Create GetFieldNamesOptions object to set instructions
var options = new GetFieldNamesOptions("path_to_your_pdf_file.pdf");
// Perform the process and get names
var fieldNames = PdfForm.GetNames(options);PDF ストリームからフィールド名を取得する例です。
// Prepare input stream
using var inputStream = File.OpenRead("path_to_your_pdf_file.pdf");
// Get field names
var fieldNames = PdfForm.GetNames(new GetFieldNamesOptions(inputStream));Documentize.GetFieldNamesOptions クラスの Input プロパティを設定する例です。
ループ処理で新しいインスタンスを作成せずに使用できます。
var options = new GetFieldNamesOptions();
// Set input from a file
options.Input = new FileData("path_to_your_pdf_file.pdf");
// Or set input from a stream
// options.Input = new StreamData(stream);
var results = PdfForm.GetNames(options);Remove(RemoveFieldsOptions) : PDF ドキュメントからフィールドを削除します。
public static ResultContainer Remove(RemoveFieldsOptions options)パラメーター
optionsRemoveFieldsOptions: 操作指示を含むオプション オブジェクト。
戻り値
ResultContainer : 操作の結果を含むオブジェクト。
使用例
PDF ファイルからフィールドを削除する例です。
// Create RemoveFieldsOptions object to set instructions
var options = new RemoveFieldsOptions();
// Add input file path
options.AddInput(new FileData("path_to_your_pdf_file.pdf"));
// Set output file path
options.AddOutput(new FileData("path_to_result_pdf_file.pdf"));
// Perform the process
PdfForm.Remove(options);例外
オプションが設定されていない場合。
Namespace: Documentize Assembly: Documentize.dll