I am working with the trial version of the Aspose PDF component and am trying to apply different styling to the text within a TextFragment component.
Hi there,
Document doc = new
Document();
Aspose.Pdf.Page page = doc.Pages.Add();
TextFragment fragment = new TextFragment();
TextSegment ts1 = new TextSegment();
ts1.Text = "Name: ";
ts1.TextState.Font = FontRepository.FindFont("Arial");
ts1.TextState.FontStyle = FontStyles.Bold;
ts1.TextState.FontSize = 12;
//ts1.TextState.LineSpacing = 13;
fragment.Segments.Add(ts1);
TextSegment ts2 = new TextSegment();
ts2.Text = "Someones First Name ";
ts2.TextState.Font = FontRepository.FindFont("Arial");
ts2.TextState.FontSize = 12;
ts2.TextState.FontStyle = FontStyles.Italic;
//ts2.TextState.LineSpacing = 13;
fragment.Segments.Add(ts2);
TextSegment ts3 = new TextSegment();
ts3.Text = "Someones Last Name";
ts3.TextState.Font = FontRepository.FindFont("Arial");
ts3.TextState.FontSize = 12;
//ts3.TextState.LineSpacing = 13;
fragment.Segments.Add(ts3);
page.Paragraphs.Add(fragment);
doc.Save("output.pdf");
Thank you so much for the reply! That is exactly what I needed.
Hi Mark,