Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
تعمل مقتطفات الشيفرة التالية أيضًا مع مكتبة Aspose.PDF.Drawing .
للحصول على القيم من جميع الحقول في مستند PDF، تحتاج إلى التنقل عبر جميع حقول النموذج ثم الحصول على القيمة باستخدام خاصية Value. احصل على كل حقل من مجموعة Form، في نوع الحقل الأساسي المسمى Field وادخل إلى خاصية Value الخاصة به.
تظهر مقتطفات الشيفرة C# التالية كيفية الحصول على قيم جميع الحقول من مستند PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetValuesFromFields()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "GetValuesFromAllFields.pdf"))
{
// Get values from all fields
foreach (Aspose.Pdf.Forms.Field formField in document.Form)
{
Console.WriteLine("Field Name : {0} ", formField.PartialName);
Console.WriteLine("Value : {0} ", formField.Value);
}
}
}
تتيح لك خاصية Value لحقل النموذج الحصول على قيمة حقل معين. للحصول على القيمة، احصل على حقل النموذج من مجموعة Form لكائن Document. يختار هذا المثال C# TextBoxField ويسترجع قيمته باستخدام خاصية Value.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetValueFromField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "GetValueFromField.pdf"))
{
// Get a field
if (document.Form["textbox1"] is Aspose.Pdf.Forms.TextBoxField textBoxField)
{
// Get field value
Console.WriteLine("PartialName : {0} ", textBoxField.PartialName);
Console.WriteLine("Value : {0} ", textBoxField.Value);
}
}
}
للحصول على عنوان URL لزر الإرسال، استخدم الأسطر التالية من الشيفرة.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetSubmitFormActionUrl()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "GetValueFromField.pdf"))
{
// Get the SubmitFormAction from the form field
if (document.Form[1].OnActivated is Aspose.Pdf.Annotations.SubmitFormAction act)
{
// Output the URL of the SubmitFormAction
Console.WriteLine(act.Url.Name);
}
}
}
في بعض الأحيان، قد تعرف مكان وجود حقل النموذج في مستند، ولكن ليس لديك اسمه. على سبيل المثال، إذا كان كل ما لديك هو مخطط لنموذج مطبوع. مع Aspose.PDF for .NET، هذه ليست مشكلة. يمكنك معرفة الحقول الموجودة في منطقة معينة من ملف PDF. للحصول على حقول النموذج من منطقة معينة من ملف PDF:
تظهر مقتطفات الشيفرة C# التالية كيفية الحصول على حقول النموذج في منطقة مستطيلة معينة من ملف PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetFieldsFromRegion()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "GetFieldsFromRegion.pdf"))
{
// Create rectangle object to get fields in that area
var rectangle = new Aspose.Pdf.Rectangle(35, 30, 500, 500);
// Get the PDF form
var form = document.Form;
// Get fields in the rectangular area
var fields = form.GetFieldsInRect(rectangle);
// Display Field names and values
foreach (var field in fields)
{
// Display image placement properties for all placements
Console.Out.WriteLine("Field Name: " + field.FullName + "-" + "Field Value: " + field.Value);
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.