Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Formクラスは、静的AcroFormを扱う機能を提供し、FormクラスのGetFieldFacade(..)メソッドを使用して特定のフィールドインスタンスを取得できます。ただし、XFAフィールドにはForm.GetFieldFacade(..)メソッドを介してアクセスできません。代わりに、Document.Form.XFAを使用してフィールド値を取得/設定し、XFAフィールドテンプレートを操作します(フィールドプロパティを設定します)。
以下のコードスニペットは、Aspose.PDF.Drawingライブラリでも動作します。
以下のコードスニペットは、XFAフォームのフィールドに入力する方法を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void FillXFAFields()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "FillXFAFields.pdf"))
{
// Get names of XFA form fields
var names = document.Form.XFA.FieldNames;
// Set field values
if (names.Length > 0)
{
document.Form.XFA[names[0]] = "Field 0";
}
if (names.Length > 1)
{
document.Form.XFA[names[1]] = "Field 1";
}
// Save PDF document
document.Save(dataDir + "FilledXfa_out.pdf");
}
}
動的フォームは、XFA(XMLフォームアーキテクチャ)として知られるXML仕様に基づいています。フォームに関する情報(PDFに関して)は非常に曖昧であり、フィールドが存在し、プロパティやJavaScriptイベントがあることを指定していますが、レンダリングについては指定していません。
現在、PDFはデータとPDFフォームを統合するための2つの異なる方法をサポートしています:
XFAフォームのページを抽出または操作することはできません。なぜなら、フォームの内容は、XFAフォームを表示またはレンダリングしようとするアプリケーション内でランタイムに生成されるからです。Aspose.PDFには、開発者がXFAフォームを標準AcroFormsに変換できる機能があります。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ConvertDynamicXFAToAcroForm()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Load dynamic XFA form
using (var document = new Aspose.Pdf.Document(dataDir + "DynamicXFAToAcroForm.pdf"))
{
// Set the form fields type as standard AcroForm
document.Form.Type = Aspose.Pdf.Forms.FormType.Standard;
// Save PDF document
document.Save(dataDir + "StandardAcroForm_out.pdf");
}
}
フィールドプロパティにアクセスするには、まずDocument.Form.XFA.Templateを使用してフィールドテンプレートにアクセスします。以下のコードスニペットは、XFAフォームフィールドのX座標とY座標を取得する手順を示しています。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetXFAProperties()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "GetXFAProperties.pdf"))
{
// Get names of XFA form fields
var names = document.Form.XFA.FieldNames;
// Set field values
if (names.Length > 0)
{
document.Form.XFA[names[0]] = "Field 0";
}
if (names.Length > 1)
{
document.Form.XFA[names[1]] = "Field 1";
}
// Get field position
if (names.Length > 0)
{
Console.WriteLine(document.Form.XFA.GetFieldTemplate(names[0]).Attributes["x"].Value);
Console.WriteLine(document.Form.XFA.GetFieldTemplate(names[0]).Attributes["y"].Value);
}
// Save PDF document
document.Save(dataDir + "FilledXfa_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.