Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
FormEditor class in Aspose.Pdf.Facades namespace offers the capability to decorate a PDF form field. Now, if your requirement is to justify the text in a textbox field, you can easily achieve that using AlignJustified value of FormFieldFacade enumeration and calling the FormEditor.DecorateField method. In the below example, first we will fill a Textbox Field using the FillField method of Form class. After that we will use FormEditor class to justify the Text in the Textbox Field. The following code snippet shows you how to justify text in a Textbox Field.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void JustifyTextInTextboxField()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();
// Open PDF document
using (var source = File.Open(dataDir + "JustifyText.pdf", FileMode.Open))
{
using (var ms = new MemoryStream())
{
// Create Form Object
var form = new Aspose.Pdf.Facades.Form();
// Bind PDF document
form.BindPdf(source);
// Fill Text Field
form.FillField("Text1", "Thank you for using Aspose");
// Save PDF document in Memory Stream
form.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
using (var dest = new FileStream(dataDir + "JustifyText_out.pdf", FileMode.Create))
{
// Create formEditor Object
using (var formEditor = new Aspose.Pdf.Facades.FormEditor())
{
// Open PDF from memory stream
formEditor.BindPdf(ms);
// Set Text Alignment as Justified
formEditor.Facade.Alignment = Aspose.Pdf.Facades.FormFieldFacade.AlignJustified;
// Decorate form field
formEditor.DecorateField();
// Save PDF document
formEditor.Save(dest);
}
}
}
}
}
Please note that justified alignment is not supported by PDF that’s why text will be aligned left when you input the text in the Textbox Field. But when field is not active text is justified.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.