Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
AddListItem 方法允许您在 ListBox 字段中添加项目。第一个参数是字段名称,第二个参数是字段项。您可以传递单个字段项,也可以传递包含项目列表的字符串数组。此方法由 FormEditor 类提供。以下代码片段演示了如何在 PDF 文件中添加列表项。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void AddListItem()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var formEditor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
formEditor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Add a ListBox field for selecting country, placed at the specified coordinates on page 1
formEditor.AddField(Aspose.Pdf.Facades.FieldType.ListBox, "Country", 1, 232.56f, 476.75f, 352.28f,
514.03f);
// Add list items to the 'Country' ListBox field
formEditor.AddListItem("Country", "USA");
formEditor.AddListItem("Country", "Canada");
formEditor.AddListItem("Country", "France");
formEditor.AddListItem("Country", "Spain");
// Save PDF document
formEditor.Save(dataDir + "Sample-Form-01-mod.pdf");
}
}
DelListItem 方法允许您从 ListBox 中删除特定项目。第一个参数是字段名称,第二个参数是您想从列表中删除的项目。此方法由 FormEditor 类提供。以下代码片段演示了如何从 PDF 文件中删除列表项。
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DelListItem()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var formEditor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
formEditor.BindPdf(dataDir + "Sample-Form-04.pdf");
// Delete the list item "France" from the 'Country' ListBox field
formEditor.DelListItem("Country", "France");
// Save PDF document
formEditor.Save(dataDir + "Sample-Form-04-mod.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.