Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
DecorateField method present in FormEditor class allows you to decorate a particular form field in a PDF file. If you want to decorate a particular field then you need to pass the field name to this method. However, before calling this method, you need to create objects of FormEditor and FormFieldFacade classes. You also need to assign the FormFieldFacade object to Facade property of the FormEditor object. After that, you can set any attributes provided by FormFieldFacade object. Once you have set the attributes, you can call the DecorateField method and finally save the updated PDF using Save method of FormEditor class. The following code snippet shows you how to decorate a particular form field.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DecorateField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var editor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
editor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Create a FormFieldFacade object to define decoration properties for the field
var cityDecoration = new Aspose.Pdf.Facades.FormFieldFacade
{
// Set the font style to Courier
Font = Aspose.Pdf.Facades.FontStyle.Courier,
// Set the font size to 12
FontSize = 12,
// Set the border color to black
BorderColor = System.Drawing.Color.Black,
// Set the border width to 2
BorderWidth = 2
};
// Assign the decoration facade to the FormEditor
editor.Facade = cityDecoration;
// Apply the decoration to the field named "City"
editor.DecorateField("City");
// Save PDF document
editor.Save(dataDir + "Sample-Form-02.pdf");
}
}
DecorateField method allows you to decorate all the form fields of a particular type in a PDF file at once. If you want to decorate all fields of a particular type then you need to pass the field type to this method. However, before calling this method, you need to create objects of FormEditor and FormFieldFacade classes. You also need to assign the FormFieldFacade object to Facade property of the FormEditor object. After that, you can set any attributes provided by FormFieldFacade object. Once you have set the attributes, you can call the DecorateField method and finally save the updated PDF using Save method of FormEditor class. The following code snippet shows you how to decorate all the fields of a particular type.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DecorateField2()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf();
// Create an instance of FormEditor to manipulate form fields
using (var editor = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
editor.BindPdf(dataDir + "Sample-Form-01.pdf");
// Create a FormFieldFacade object to define alignment properties for text fields
var textFieldDecoration = new Aspose.Pdf.Facades.FormFieldFacade
{
// Set text alignment to center
Alignment = Aspose.Pdf.Facades.FormFieldFacade.AlignCenter
};
// Assign the decoration facade to the FormEditor
editor.Facade = textFieldDecoration;
// Apply the alignment decoration to all text fields in the PDF
editor.DecorateField(Aspose.Pdf.Facades.FieldType.Text);
// Save PDF document
editor.Save(dataDir + "Sample-Form-01-align-text.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.