필드 외관 및 속성

구현 세부정보

SetFieldAppearance 메서드는 양식 필드의 외관을 변경하는 데 사용됩니다. 이 메서드는 AnnotationFlag를 매개변수로 사용합니다. AnnotationFlag는 Hidden 또는 NoRotate와 같은 다양한 멤버를 가진 열거형입니다.

SetFieldAttributes 메서드는 양식 필드의 속성을 변경하는 데 사용됩니다. 이 메서드에 전달되는 매개변수는 ReadOnly 또는 Required와 같은 멤버를 포함하는 PropertyFlag 열거형입니다.

FormEditor 클래스는 필드 한계를 설정하는 메서드도 제공합니다. 이 메서드는 필드가 얼마나 많은 문자를 채울 수 있는지를 알려줍니다. 아래 코드 스니펫은 이러한 모든 메서드를 사용하는 방법을 보여줍니다.

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

     // Open PDF document
     using (var doc = new Aspose.Pdf.Document(dataDir + "FilledForm.pdf"))
     {
         // Create an instance of FormEditor to manipulate form fields
         using (var formEditor = new Aspose.Pdf.Facades.FormEditor(doc))
         {
             // Add a new text field to the form on page 1 at the specified coordinates and size
             formEditor.AddField(Aspose.Pdf.Facades.FieldType.Text, "text1", 1, 200, 550, 300, 575);

             // Set the field attribute to make the text field required (user must fill it)
             formEditor.SetFieldAttribute("text1", Aspose.Pdf.Facades.PropertyFlag.Required);

             // Set a character limit for the field (maximum 20 characters)
             formEditor.SetFieldLimit("text1", 20);

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