ملء AcroForm - ملء نموذج PDF باستخدام C#

تعمل مقتطفات الشيفرة التالية أيضًا مع مكتبة Aspose.PDF.Drawing .

ملء حقل النموذج في مستند PDF

لملء حقل النموذج، احصل على الحقل من مجموعة النموذج في كائن المستند. ثم قم بتعيين قيمة الحقل باستخدام خاصية القيمة للحقل.

هذا المثال يختار TextBoxField ويقوم بتعيين قيمته باستخدام خاصية القيمة.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void FillFormField()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "FillFormField.pdf"))
    {
        // Get a field
        if (document.Form["textbox1"] is Aspose.Pdf.Forms.TextBoxField textBoxField)
        {
            // Modify field value
            textBoxField.Value = "Value to be filled in the field";
        }

        // Save PDF document
        document.Save(dataDir + "FillFormField_out.pdf");
    }
}