Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
تقدم فئة النموذج القدرة على التعامل مع 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");
}
}
تستند النماذج الديناميكية إلى مواصفة XML تعرف باسم XFA، “بنية النماذج XML”. المعلومات حول النموذج (بقدر ما يتعلق الأمر بـ PDF) غامضة جدًا - تحدد أن الحقول موجودة، مع خصائص، وأحداث JavaScript، ولكن لا تحدد أي عرض.
حاليًا، يدعم PDF طريقتين مختلفتين لدمج البيانات ونماذج PDF:
لا يمكننا استخراج أو التلاعب بصفحات نماذج XFA، لأن محتوى النموذج يتم إنشاؤه في وقت التشغيل (أثناء عرض نموذج 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 للوصول إلى قالب الحقل. تظهر مقتطفات الكود التالية خطوات الحصول على إحداثيات X و Y لحقل نموذج XFA.
// 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.