i want to use different font on part of the wording in a table cell. i tried text and segment both give me the text i want however the font i want was not effecting. code as below. i want UPHS Office of Medical Affairs to be bold.
Dim text1 As Aspose.Pdf.Text = New Aspose.Pdf.Text
Dim seg1 As Segment = text1.Segments.Add(" UPHS Office of Medical Affairs ")
seg1.TextInfo.FontName = "Arial Black"
seg1.TextInfo.IsTrueTypeFontBold = True
Dim Provrow5 As Row = ProviderTable.Rows.Add()
' Dim Provrow5col As Cell = Provrow5.Cells.Add("The" & text1.Segments.Item(0).Content & part2 & provider & " " & part3)
Dim Provrow5col As Cell = Provrow5.Cells.Add("The" & seg1.Content & part2 & provider & " " & part3)
In order to specify the font information for a specific text with in a text string, you can try using the InLineHTML technique of Text object. You can specify the specific font information as well as formatting information for the text object.
Please try using the following code snippet to accomplish your requirement. I've also attached a resultant PDF document for the reference purpose. Please take a look.
[VB.NET]
'Instantiate a pdf document Dim pdf1 As Pdf = New Pdf() 'Create a section in the pdf document Dim sec1 As Aspose.Pdf.Section = pdf1.Sections.Add() 'Create string variables with text containing html tags Dim s As String = " This is a test of HTML support for UPHS Office of Medical Affairs."
'Create text paragraphs containing HTML text Dim t1 As Text = New Text(s) ' set the value to render HTML tags according to tag value t1.IsHtmlTagSupported = True ' set the Unicode property to true so that Unicode font is used t1.TextInfo.IsUnicode = True
'Instantiate a table object Dim tab1 As Table = New Table() 'Add the table in paragraphs collection of the desired section sec1.Paragraphs.Add(tab1) 'Set with column widths of the table tab1.ColumnWidths = "150 150" 'Set default cell border using BorderInfo object tab1.DefaultCellBorder = New BorderInfo(BorderSide.All, 0.1F) 'Set table border using another customized BorderInfo object tab1.Border = New BorderInfo(BorderSide.All, 1.0F)
'Create MarginInfo object and set its left, bottom, right and top margins Dim margin As MarginInfo = New MarginInfo() margin.Top = 5.0F margin.Left = 5.0F margin.Right = 5.0F margin.Bottom = 5.0F 'Set the default cell padding to the MarginInfo object tab1.DefaultCellPadding = margin 'Create rows in the table and then cells in the rows Dim row1 As Aspose.Pdf.Row = tab1.Rows.Add() row1.Cells.Add().Paragraphs.Add(t1) row1.Cells.Add("Normal Text")
thanks for your help. however it is not exactly what i am looking for. i need both text in one cell. in one cell i need bold some text and leave rest of normal.