Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
لإضافة حقل نموذج في ملف PDF موجود، تحتاج إلى استخدام AddField من فئة FormEditor. تتطلب هذه الطريقة منك تحديد نوع الحقل الذي تريد إضافته مع الاسم وموقع الحقل. تحتاج إلى إنشاء كائن من فئة FormEditor، واستخدام AddField لإضافة حقل جديد في PDF، كما يمكنك تحديد حد لعدد الأحرف في حقل الخاص بك باستخدام SetFieldLimit وأخيرًا استخدام Save لحفظ ملف PDF المحدث. يوضح لك مقتطف الكود التالي كيفية إضافة حقل نموذج في ملف PDF موجود.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var editor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
editor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Add a text field named "Country" to the first page of the PDF
// Specify the coordinates of the field (left, bottom, right, top)
editor.AddField(Aspose.Pdf.Facades.FieldType.Text, "Country", 1, 232.56f, 496.75f, 352.28f, 514.03f);
// Set a character limit for the "Country" field to 20 characters
editor.SetFieldLimit("Country", 20);
// Save PDF document
editor.Save(dataDir + "Sample-Form-01-mod.pdf");
}
}
تتيح لك طريقة AddSubmitBtn تعيين عنوان URL لزر الإرسال في ملف PDF. هذا هو عنوان URL الذي يتم نشر البيانات عليه عند النقر على زر الإرسال. في كود المثال الخاص بنا، نحدد عنوان URL، واسم حقلنا، ورقم الصفحة التي نريد الإضافة إليها، وإحداثيات وضع الزر. تتطلب طريقة AddSubmitBtn اسم حقل زر الإرسال وعنوان URL. يتم توفير هذه الطريقة من قبل فئة FormEditor. يوضح لك مقتطف الكود التالي كيفية تعيين عنوان URL لزر الإرسال.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddSubmitBtn()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var editor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
editor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Add a submit button named "Submit" to the first page of the PDF
// Specify the button text ("Submit"), the URL to which the form data will be submitted,
// and the coordinates of the button (left, bottom, right, top)
editor.AddSubmitBtn("Submit", 1, "Submit", "http://localhost:3000", 232.56f, 466.75f, 352.28f, 484.03f);
// Save PDF document
editor.Save(dataDir + "Sample-Form-01-mod.pdf");
}
}
تتيح لك طريقة AddFieldScript إضافة JavaScript إلى زر دفع في ملف PDF. تتطلب هذه الطريقة اسم زر الدفع وJavaScript. يتم توفير هذه الطريقة من قبل فئة FormEditor. يوضح لك مقتطف الكود التالي كيفية تعيين JavaScript لزر الدفع.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddFieldScript()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var editor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
editor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Add a JavaScript action to the field named "Last Name"
// The script displays an alert box with the message "Only one last name"
editor.AddFieldScript("Last Name", "app.alert(\"Only one last name\",3);");
// Save PDF document
editor.Save(dataDir + "Sample-Form-01-mod.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.