Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
O método SetFieldAppearance é usado para alterar a aparência de um campo de formulário. Ele recebe AnnotationFlag como parâmetro. AnnotationFlag é uma enumeração que possui diferentes membros como Hidden ou NoRotate, etc.
O método SetFieldAttributes é usado para alterar o atributo de um campo de formulário. Um parâmetro passado para este método é a enumeração PropertyFlag, que contém membros como ReadOnly ou Required, etc.
A classe FormEditor também fornece um método para definir o limite do campo. Ele informa ao campo quantos caracteres podem ser preenchidos. O trecho de código abaixo mostra como todos esses métodos podem ser usados.
// 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");
}
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.