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

Free Support Forum - aspose.com

Not able to use TextFragment.TextState.FontStyle for pdf .NET

I am not able to use TextFragment.TextState.FontStyle for pdf .NET, though it does not give error but during runtime, getting empty value for this parameter. Not even able to set to Bold.


Can you please share which version of the API are you using? Can you please share a sample console application through which the issue can be reproduced? We will further proceed to assist you accordingly.

I am using 18.5.0 version. And below is the sample code, it does not give build errors or runtime errors, but while debugging there is no FontStyle attribute seen for TextState.
TextSegment segmentToBeBold = new TextSegment(strSubstringArr[1]); TextState textToBeBold = new TextState(); textToBeBold.LineSpacing = 15; textToBeBold.FontSize = 18; textToBeBold.Font = fontStreams.bodyFont; textToBeBold.ForegroundColor = bodyFragment.TextState.ForegroundColor; textToBeBold.FontStyle = FontStyles.Bold; segmentToBeBold.TextState = textToBeBold; updatedBodyFragment.Segments.Add(segmentToBeBold);


Please try to use the latest version of the API i.e. 22.4. Also, please make sure that to include Aspose.Pdf.Text namespace in your program. In case issue still persists, please share a sample console application for our reference that can reproduce the issue. We will test and address it accordingly.