Multiline Read-Only TextBoxField

I have created a multi-line Read-Only TextBoxField with the code below, but it only appears as a multi-line box in the pdf if I click on it. Is there a way to make it always display as a multi-line Text box?

TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300));

textBoxField.PartialName = "textbox1";

textBoxField.Value = "This is an important Read-Only Multi-Line \n Text Box";

Border border = new Border(textBoxField);

border.Width = 5;

border.Dash = new Dash(1, 1);

textBoxField.Border = border;

textBoxField.Multiline = true;

textBoxField.ReadOnly = true;

pdfDocument.Form.Add(textBoxField, 1);

pdfDocument.Save("output.pdf");

Hi Daniel,


Thanks for using our API.

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-37107 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.<o:p></o:p>

Hi Daniel,


Thanks for your patience. We have investigated your code and fount that Multline flag is being set after setting Value property, that’s why appearance is not updated properly. You should set Multiline flag before setting text, this will work in current version (9.5 and earlier). However we have fixed this issue in Aspose.Pdf for .NET 9.6.0. It will be released in this week or start of next week.

Moreover, it is also recommended to specify default appearance (desired font and font size). If default appearance is not specified then TextBoxField tries automatically select largest font size for which all text may be placed in text box rectangle.

Document pdfDocument = new Document();<o:p></o:p>

pdfDocument.Pages.Add();

TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100, 200, 300, 300));

textBoxField.PartialName = "textbox1";

textBoxField.Multiline = true;

textBoxField.DefaultAppearance = new DefaultAppearance("Helvetica", 12, System.Drawing.Color.Black);

textBoxField.Value = "This is an important Read-Only Multi-Line \n Text Box";

Border border = new Border(textBoxField);

border.Width = 5;

border.Dash = new Dash(1, 1);

textBoxField.Border = border;

textBoxField.Multiline = true;

textBoxField.ReadOnly = true;

pdfDocument.Form.Add(textBoxField, 1);

pdfDocument.Save(myDir+"TextBoxAdded_output.pdf");

Please feel free to contact us for any further assistance.


Best Regards,



The issues you have found earlier (filed as PDFNEWNET-37107) have been fixed in Aspose.Pdf for .NET 9.6.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.