Format text in textbox

Dear supporters,


When I test aspose.pdf for my product, I have requirement to format text in a textbox field. Please guide me to do it.

Thanks.

Hi,

Sorry for a delay in response.

Please see the following documentation link for details and sample code regarding decorating the form field. You can use different properties like TextColor and Font of FormFieldFacade class to format your text field.

  1. Decorate a Particular Form Field in an Existing PDF File
  2. Decorate All Fields of a Particular Type in an Existing PDF File

Please feel free to contact support in case you need any further assistance.

Sorry for the inconvenience,

Hi Nausherwan Aslam,


May I need a help from you for this problem once more. I want format each text paragraph in a textbox field. Example, paragraph A is bold but paragraph B is italic. Please recommend a way to do this.

Many thanks for your support

Hi,

I think this can be possible if you are using a RichTextBox Field in your input file. Normal Textbox does not allow this feature (You may check and verify it using Adobe Acrobat). You may check the following sample code in this regard and see if this can help you in achieving your desired results.

Document pdfDocument = new Document(@"input.pdf");

RichTextBoxField textBoxField = pdfDocument.Form["Name"] as RichTextBoxField;
textBoxField.FormattedValue = "<b>Text</b> <i>Value</i>";

pdfDocument.Save(@"output.pdf");

Please feel free to contact support in case you need any further assistance.

Sorry for the inconvenience,