Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
El siguiente fragmento de código también funciona con la biblioteca Aspose.PDF.Drawing.
El método SetFieldLimit(field, limit) de la clase FormEditor le permite establecer un límite de campo, el número máximo de caracteres que se pueden ingresar en un campo.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SetFieldLimit()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Create FormEditor instance
using (var form = new Aspose.Pdf.Facades.FormEditor())
{
// Bind PDF document
form.BindPdf(dataDir + "input.pdf");
// Set field limit for "textbox1"
form.SetFieldLimit("textbox1", 15);
// Save PDF document
form.Save(dataDir + "SetFieldLimit_out.pdf");
}
}
De manera similar, Aspose.PDF tiene un método que obtiene el límite de campo utilizando el enfoque DOM. El siguiente fragmento de código muestra los pasos.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetFieldLimitUsingDOM()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "FieldLimit.pdf"))
{
// Get the field and its maximum limit
if (document.Form["textbox1"] is Aspose.Pdf.Forms.TextBoxField textBoxField)
{
Console.WriteLine("Limit: " + textBoxField.MaxLen);
}
}
}
También puede obtener el mismo valor utilizando el espacio de nombres Aspose.Pdf.Facades con el siguiente fragmento de código.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void GetFieldLimitUsingFacades()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Create Form instance
using (var form = new Aspose.Pdf.Facades.Form())
{
// Bind PDF document
form.BindPdf(dataDir + "FieldLimit.pdf");
// Get the field limit for "textbox1"
Console.WriteLine("Limit: " + form.GetFieldLimit("textbox1"));
}
}
Los campos de formulario en archivos PDF de Adobe pueden configurarse para usar fuentes predeterminadas específicas. En las primeras versiones de Aspose.PDF, solo se admitían las 14 fuentes predeterminadas. Las versiones posteriores permitieron a los desarrolladores aplicar cualquier fuente. Para establecer y actualizar la fuente predeterminada utilizada para los campos de formulario, utilice la clase DefaultAppearance(Font font, double size, Color color). Esta clase se puede encontrar en el espacio de nombres Aspose.Pdf.InteractiveFeatures. Para usar este objeto, utilice la propiedad DefaultAppearance de la clase Field.
El siguiente fragmento de código muestra cómo establecer la fuente predeterminada para los campos de formulario PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void SetFormFieldFont()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "FormFieldFont14.pdf"))
{
// Get particular form field from document
if (document.Form["textbox1"] is Aspose.Pdf.Forms.Field field)
{
// Create font object
var font = Aspose.Pdf.Text.FontRepository.FindFont("ComicSansMS");
// Set the font information for form field
field.DefaultAppearance = new Aspose.Pdf.Annotations.DefaultAppearance(font, 10, System.Drawing.Color.Black);
}
// Save PDF document
document.Save(dataDir + "FormFieldFont14_out.pdf");
}
}
Todos los campos de formulario están contenidos en la colección Form del objeto Document. Esta colección proporciona diferentes métodos que gestionan los campos de formulario, incluido el método Delete. Si desea eliminar un campo en particular, pase el nombre del campo como parámetro al método Delete y luego guarde el documento PDF actualizado. El siguiente fragmento de código muestra cómo eliminar un campo en particular de un documento PDF.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DeleteFormField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "DeleteFormField.pdf"))
{
// Delete a particular field by name
document.Form.Delete("textbox1");
// Save PDF document
document.Save(dataDir + "DeleteFormField_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.