목록 항목 작업

기존 PDF 파일에 목록 항목 추가

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");
     }
 }

기존 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");
     }
 }