Rtf text in cell - PDF generator

Dear Sirs

Is it possible to insert RTF formatted text in a cell in a table using the PDF generator ?

Best regards

Hi Mads,<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” />

Sorry for a delayed response.

I think you may try Text.IsHtmlTagSupported option to achieve your desired results. Please see the documentation link for more details.

[HTML Tags in Text](http://www.aspose.com/docs/display/pdfnet/HTML+Tags+in+Text)

Also, following is the sample code.

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add();
Aspose.Pdf.Generator.Table tblDocData = new Aspose.Pdf.Generator.Table();
tblDocData.DefaultCellTextInfo.FontName = "Arial";
tblDocData.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
tblDocData.ColumnWidths = ("150 250");
DataTable dtDocuments = new DataTable();
dtDocuments.Columns.Add("1", System.Type.GetType("System.String"));
dtDocuments.Columns.Add("2", System.Type.GetType("System.String"));
for (int row = 0; row <= 10; row++)
{
DataRow dr = dtDocuments.NewRow();
dr[0] = "Status *Testing* " + row.ToString();
dr[1] = "Document " + row.ToString();
dtDocuments.Rows.Add(dr);
}
dtDocuments.AcceptChanges();
Aspose.Pdf.Generator.Row rDocHeader = tblDocData.Rows.Add();
Aspose.Pdf.Generator.Cell c1header = rDocHeader.Cells.Add("Status");
Aspose.Pdf.Generator.Cell c2header = rDocHeader.Cells.Add("Document Name");
int i;
for (i = 0; i <= dtDocuments.Rows.Count - 1; i++)
{
Aspose.Pdf.Generator.Row r11 = tblDocData.Rows.Add();
int j;
for (j = 0; j <= dtDocuments.Columns.Count - 1; j++)
{
Aspose.Pdf.Generator.Cell clbl = r11.Cells.Add();
string s = (dtDocuments.Rows[i][j]).ToString();
Aspose.Pdf.Generator.Text text1 = new Text(s);
text1.IsHtmlTagSupported = true;
clbl.Paragraphs.Add(text1);
}
}
pdf.SetUnicode();
sec1.Paragraphs.Add(tblDocData);
pdf.Save(@"d:\ap data\july2012\Table_HTML_Formating.pdf");

If you have any other requirement or query, please feel free to contact us.

Thank You & Best Regards,

Thank you for the suggestion, but my input is i RTF not XHTML

If i convert Rtf to XHTML with Aspose Words, the format canges , ex.

linespacing is doubled compared to the rtf file. ?

Best regards

Hi Mads,


Thanks for using our products.

Please note that if you have contents in RTF format, then I would recommend you to please try using Aspose.Words for converting into PDF format. You may also consider placing all the contents in RTF file and then save it into PDF format using Aspose.Words for .NET.

In case I have not properly understood your requirement, please share some further details.