Hello There,
Thanks for using our API’s.
I have tested the scenario with your code, after little modification in your code and I have managed to get the expected output. I have attached the output PDF document and sample code for your reference.
<span class=“kwrd” style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>Dim<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”> doc <span class=“kwrd” style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>As<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”> <span class=“kwrd” style=“font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”>New<span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”, Consolas, Courier, monospace; font-size: small; white-space: pre;”> Document()
Dim page As Page = doc.Pages.Add()
Dim table As New Table()
page.Paragraphs.Add(table)
Dim row As Row = table.Rows.Add()
Dim cell As Cell = row.Cells.Add()
Dim t As New Aspose.Pdf.Text.TextFragment()
Dim d1 As New Aspose.Pdf.Text.TextSegment(“MyText1”)
t.Segments.Add(d1)
Dim d2 As New Aspose.Pdf.Text.TextSegment(“MyText2”)
d2.TextState.ForegroundColor = Aspose.Pdf.Color.White
d2.TextState.BackgroundColor = Aspose.Pdf.Color.Blue
d2.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold
t.Segments.Add(d2)
cell.Paragraphs.Add(t)
doc.Save(dataDir + “outputdoc.pdf”)
If you still face any issue, please feel free to contact us for further assistance.
Best Regards,