Set LineHeight Multiline Aspose.Pdf.Forms.RichTextBoxField Line-Height - Aspose.PDF for .NET

Could you please provide samples of a supported RichTextValue that will allow setting the line-height for each line of a multiline Aspose.Pdf.Forms.RichTextBoxField?

I’ve tested with the Xml value below, but it causes errors when opening the Pdf.

“An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.”

<?xml version=\"1.0\"?><body xfa:APIVersion=\"Acroform:2.7.0.0\" xfa:spec=\"2.1\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">1</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">2</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">3</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">4</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">5</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">6</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">7</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">8</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">9</p><p dir=\"ltr\" style=\"margin-top:0pt;margin-bottom:0pt;line-height:7pt;font-family:Arial;font-size:7pt\">10</p></body>


This Topic is created by codewarior using the Email to Topic plugin.

Hi,

Thanks for contacting support.

As per my understanding, you need to set the line height of a multiline form field. If so is the case, then please try using following code snippet. Or if your requirement is to create the document using HTML file, then once the conversion is performed, you need to get reference of TextBoxField and then update its properties.

[C#]
// Open document
Document pdfDocument = new Document();
// add page to pages collection of PDF file
pdfDocument.Pages.Add();
// create RichTextBoxField
Aspose.Pdf.Forms.RichTextBoxField field = new Aspose.Pdf.Forms.RichTextBoxField(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(100,100,230,230));
// set height of form field
field.Height = 100;
// enable multiline for form field
field.Multiline = true;
// the default value for form field
field.Value = "A multi line form field \n new line";
// add RichTextBoxField to forms collection of PDF file
pdfDocument.Form.Add(field);
// Save updated document
pdfDocument.Save("c:/pdftest/MultiLine.pdf");

Thank you for the quick response.

However, I’m not seeing how to control the line-height (spacing between lines) in your sample code. I see where you’re setting the height of the field, but not the line-height of the multiline values. It appears this would be controlled through the RichTextValue property, but I’m unable to get it working properly.

Thanks for your help…

It appears that the line-height (spacing between lines) style is not being recognized in either the Style or Value properties.

Test Using Style Property:

   var richText = (RichTextBoxField) doc.Form.Fields[0];
   richText.Style = "margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt";
   richText.Value = "1\n2\n3\n4\n5\n6\n7\n8\n9\n10";

Test Using Value property:

   var richText = (RichTextBoxField) doc.Form.Fields[0];
   richText.Value = "<body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\"><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">1</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">2</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">3</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">4</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">5</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">6</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">7</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">8</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">9</p><br><p style=\"margin-top:0pt;line-height:7pt;font-family:Arial;font-size:7pt;\">10</p></body>";

Can you please provide a sample of setting the line-height (spacing between lines) on a RichTextBoxField?

Thanks,

Hi Chris,

Thanks for contacting support and sharing the details.

I have tested the scenario and have also managed to reproduce above stated issue that spacing between lines in RickTextBoxField are not being honored. For the sake of correction, I have logged it as PDFNET-42933 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.

Thank you very much!

Please let me know if you need anything additional…

:slight_smile:

Hi Chris,

In case we need any additional details during the investigation process, we will surely let you know.

Hey Codewarior,

Do you have any estimated timeframe on when you will be able to update us on your investigation? This is a critical issue for us and we’d welcome any estimate you can provide on your progress. Thanks so much! Tom

Hi Chris,

Thanks for contacting support.

As we just have been able to notice this problem, so it is pending for review and unless the investigation is completed, we may not be able to share the possible timelines regarding its resolution. As soon as we have some further updates, we will let you know.

Thank you for your prompt attention to this matter.

@Chris,

Thanks for your patience.

We are pleased to share that the issue PDFNET-42933 reported earlier is resolved in recent release of
Aspose.Pdf for .NET 17.9.

Please try using the latest release and in case you face any issue, please feel free to contact.