Free Support Forum - aspose.com

Embed list inside text paragraph

Hi, I’m using Aspose.PDF.Generator for .NET 3.5. So far the aspose API has all the functionality I need, but I don’t know how to embed a list inside a text paragraph.

Example:

Paragraph Starts here
  1. Element 1
  2. Element 2
Paragraph ends here

I checked out the ListSection object but since the list will be in another section, I don’t think this is suitable.

What can I do?

Hi Mikael,


Thanks for contacting support and sorry for the delayed response.

In order to accomplish your requirement, I would suggest you to use HTML tags inside text paragraph. Please try using the following code snippet. For your reference, I have also attached the resultant file generated over my end.


You may also check HTML Tags in Text

[C#]

//Instantiate a pdf document<o:p></o:p>

Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

//Create a section in the pdf document

Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

//Create string variables with text containing html tags

string s = "

Paragraph Starts here

  1. Element 1
  2. Element 2

Paragraph ends here

";

//Create text paragraphs containing HTML text

Aspose.Pdf.Generator.Text text1 = new Aspose.Pdf.Generator.Text(s);

text1.IsHtmlTagSupported = true;

//Add the text paragraphs containing HTML text to the section

sec1.Paragraphs.Add(text1);

//Save the pdf document

pdf1.Save("c:/pdftest/TestHtml.pdf");