We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Partial italic inside table cell

Hello,

I need to have text like this sample inside a single table cell. How can I control properties like italic and bold for specific pieces of text within a single cell?
Thanks,
Mark

Current Diagnosis:

<span style=“font-size:10.0pt;font-family:
Arial;mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:Arial;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-font-weight:bold”>(If
changed or added, please document criteria met and who provided diagnosis. Forward any new or updated assessment
information.)

Hello Mark,

Thanks for using our products.,

Please take a look over the following code snippet to accomplish your requirement. I have also attached the resultant PDF that I have generated using Aspose.Pdf for .NET 4.5.0

[C#]

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

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
sec1.Paragraphs.Add(table1);
table1.ColumnWidths = "70 2cm";

Aspose.Pdf.Row row1 = table1.Rows.Add();
Aspose.Pdf.TextInfo ItalicTextInfo = new Aspose.Pdf.TextInfo();
ItalicTextInfo.IsTrueTypeFontItalic= true;
Aspose.Pdf.Cell cell1Row2 = row1.Cells.Add("Italic Text",ItalicTextInfo);
cell1Row2.Border = new BorderInfo((int)BorderSide.All,0.5F);

Aspose.Pdf.TextInfo BoldTextInfo = new Aspose.Pdf.TextInfo();
BoldTextInfo.IsTrueTypeFontBold=true;
Aspose.Pdf.Cell cell2Row2 = row1.Cells.Add("Bold Text",BoldTextInfo);
cell2Row2.Border = new BorderInfo((int)BorderSide.All,0.5F,new Aspose.Pdf.Color("Red"));
pdf1.Save(@"d:/pdftest/TextFormatting_InsideTableCell.pdf");

In case it does not satisfy your requirement or you have any further query, please feel free to contact.

Thank you for your response. In this case my requirements are a little different. I need to have a paragraph in a cell where parts of the paragraph are bold and other parts of the paragraph are italic. I need multiple styles within the same cell.


This would be a sample of a paragraph that would be in a single cell.

Current Diagnosis:

<span style=“font-size:10.0pt;font-family:
Arial;mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:Arial;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-font-weight:bold”>(If
changed or added, please document criteria met and who provided diagnosis. Forward any new or updated assessment
information.)


Thanks,
Mark

Hello Mark,

Please take a look over the following code snippet to accomplish your requirement.

[C#]

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

Aspose.Pdf.Table table1 = new Aspose.Pdf.Table();
sec1.Paragraphs.Add(table1);
table1.ColumnWidths = "200";

Aspose.Pdf.Row row1 = table1.Rows.Add();
Aspose.Pdf.Cell HTMLTextCell = new Aspose.Pdf.Cell(row1);

Text SampleText = new Text("Current Diagnosis:
(If changed or added, please document criteria met and who provided diagnosis. Forward any new or updated assessment information.) ");
// Enable this value to render text as per their HTML TAG
SampleText.IsHtmlTagSupported = true;

HTMLTextCell.Paragraphs.Add(SampleText);
row1.Cells.Add(HTMLTextCell);
HTMLTextCell.Border = new BorderInfo((int)BorderSide.All, 0.5F);

pdf1.Save(@"d:/pdftest/TextFormatting_InsideTableCell.pdf");

I would recommend you to visit the following link for information on topics covered in above code snippet. HTML Tags in Text

The resultant PDF that I have generated is also in attachment, please take a look. In case I have not properly understood your requirements or you have any further query, please feel free to contact.

Hello Mark,

Please find below the required code snippet.

[VB.NET]

Dim pdf1 As Pdf = New Pdf()
Dim sec1 As Aspose.Pdf.Section = pdf1.Sections.Add()

Dim table1 As Aspose.Pdf.Table = New Aspose.Pdf.Table()
sec1.Paragraphs.Add(table1)
table1.ColumnWidths = "200"

Dim row1 As Aspose.Pdf.Row = table1.Rows.Add()
Dim HTMLTextCell As Aspose.Pdf.Cell = New Aspose.Pdf.Cell(row1)

Dim SampleText As Text = New Text("Current Diagnosis: (If changed or added, please document criteria met and who provided diagnosis. Forward any new or updated assessment information.) ")
' Enable this value to render text as per their HTML TAG
SampleText.IsHtmlTagSupported = True

HTMLTextCell.Paragraphs.Add(SampleText)
row1.Cells.Add(HTMLTextCell)
HTMLTextCell.Border = New BorderInfo(BorderSide.All, 0.5F)

pdf1.Save("d:/pdftest/TextFormatting_InsideTableCell.pdf")

In case I can be of any further assistance, please let me know.