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

Free Support Forum - aspose.com

PDF FontStyles

Hi,
We are using Aspose to generate pdfs in our application. We have a requirement of applying style for a particular word in a PDF. We tried the FontStyles.Bold option. It doesn’t throw any exception on the usage. But its not getting applied on the PDF.
Aspose dll verion: 18.5.0.0. Please help us to resolve this issue.

@ragudisprz Could you please specify which of Aspose products you use for PDF creation Aspose.PDF or Aspose.Words?

Hi Alexey,
We are using Aspose.PDF.

@ragudisprz I will move your request into Aspose.PDF forum. My colleagues will help you shortly.

Thanks Alexey :slight_smile:

Hi,
Any possible solution for this?

@ragudisprz

You can apply font at text fragment or text segment level. We suggest you please check the code examples shared in following article.
Text Formatting inside PDF using C#

`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.Underline = true;
                    //Main part of code responsible for Text to be Bold.
                    textToBeBold.FontStyle = FontStyles.Bold;
                    segmentToBeBold.TextState = textToBeBold;
                    updatedBodyFragment.Segments.Add(segmentToBeBold);`

This is how we are applying the FontStyle.

@ragudisprz

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please attach the expected output PDF file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.