Posted by a ceTe Software moderator
Hello,
The Text property on FormattedTextArea just returns the HTML text you assigned to it and it does not return the rendered text. So if you assign this HTML text directly to the text field, it will display the html text as-is without rendering the tags, because the PDF text field is not capable of rendering HTML tags. It is not possible to fill the text field with rendered HTML text and let the user edit that text. What you can do is, remove the text field and replace it with the FormattedTextArea that you have created with the HTML text.
Here is the proof of concept code that shows how to replace the text field with a FormattedTextArea:
// Create a PDF Document with text field.
Document document = new Document();
Page page = new Page(PageSize.Letter);
ceTe.DynamicPDF.PageElements.Forms.TextField textField = new ceTe.DynamicPDF.PageElements.Forms.TextField("txtField", 50, 75, 250, 250);
textField.MultiLine = true;
page.Elements.Add(textField);
document.Pages.Add(page);
//Save and open the PDF that contains the text field.
PdfDocument pdf = new PdfDocument(document.Draw());
MergeDocument mergeDoc = new MergeDocument(pdf);
//remove the text field from the form.
mergeDoc.Form.Fields["txtField"].Output = FormFieldOutput.Remove;
PdfFormField txtField = pdf.Form.Fields["txtField"];
Page txtFieldPage = mergeDoc.Pages[txtField.GetOriginalPageNumber()-1];
string formattedText = "<p>Formatted text area provide rich formatting support for text that " +
"appears in the document. You have complete control over 8 paragraph properties: " +
"spacing before, spacing after, first line indentation, left indentation, right " +
"indentation, alignment, allowing orphan lines, and white space preservation; 6 " +
"font properties: <font face='Times'>font face, </font><font " +
"pointSize='6'>font size, </font><font color='FF0000'>color, " +
"</font><b>bold, </b><i>italic and </i><u>" +
"underline</u>; and 2 line properties: leading, and leading type. Text can " +
"also be rotated.</p>";
//create a FormattedTextArea and add it in place of the removed text field.
FormattedTextAreaStyle style = new FormattedTextAreaStyle(ceTe.DynamicPDF.FontFamily.Helvetica, 10, true);
FormattedTextArea area = new FormattedTextArea(formattedText, txtField.GetX(txtFieldPage), txtField.GetY(txtFieldPage), txtField.Width, txtField.Height, style);
txtFieldPage.Elements.Add(area);
mergeDoc.Draw("Final.pdf");
Thanks,
ceTe Software Support Team.