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

Free Support Forum - aspose.com

Bolding a sentence in a Paragraph

Hi Aspose Team,



I’ve searched but couldn’t find a solution to this issue. I need a specific sentence to be BOLD inside of a paragraph.



I’m familiar with turning an entire paragraph BOLD but not 1 sentence within a paragraph.



This string will be pulled from the database so I could add some manipulation into the string as needed or even when the string is pulled into my application.



Example Paragraph:



On Monday night’s season premiere of The Big Bang Theory, Penny (Kaley Cuoco) debuted a new pixie haircut. And the show didn’t even bother to try to pretend it was a big deal. When Leonard (Johnny Galecki) planned to pick up Sheldon (Jim Parsons) from Arizona, Penny declined to accompany him — because of her new haircut.



Result I want:

On Monday night’s season premiere of The Big Bang Theory, Penny (Kaley Cuoco) debuted a new pixie haircut. And the show didn’t even bother to try to pretend it was a big deal. When Leonard (Johnny Galecki) planned to pick up Sheldon (Jim Parsons) from Arizona, Penny declined to accompany him — because of her new haircut.

Hi Gilbert,

Thanks for inquiring Aspose.Slides.

I have observed your desired text rendering requirement. I like to share that we have collection of portions associated with every paragraph. All the text related properties like bold, italicize, underline, font color, height etc are managed on portion level. If the entire paragraph has same text formatting then we have one portion in that paragraph by default. If there is a single change in formatting of text then we will have a separate portion for that. Please visit the documentation link for developing concepts about paragraph portions and working with text related properties for your kind reference.

I have also generated the sample code to serve your requirement and you can please try using the same on your end.

Presentation pres=new Presentation();
ISlide slide=pres.Slides[0];;

String st1="On Monday night’s season premiere of The Big Bang Theory, Penny (Kaley Cuoco) debuted a new pixie haircut. ";
String st2=“And the show didn’t even bother to try to pretend it was a big deal. “;
String st3=“When Leonard (Johnny Galecki) planned to pick up Sheldon (Jim Parsons) from Arizona, Penny declined to accompany him — because of her new haircut.”;

IAutoShape shape=slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 400, 250);
shape.FillFormat.FillType=FillType.NoFill;

shape.AddTextFrame(””);
ITextFrame text=shape.TextFrame;

IParagraph para=text.Paragraphs[0];

IPortion portion1=para.Portions[0];
portion1.Text=st1;
portion1.PortionFormat.FillFormat.FillType=FillType.Solid;
portion1.PortionFormat.FillFormat.SolidFillColor.Color=Color.Black;


IPortion portionBold=new Portion();
portionBold.Text=st2;
portionBold.PortionFormat.FontBold=NullableBool.True;
portionBold.PortionFormat.FontItalic=NullableBool.True;
portionBold.PortionFormat.FontUnderline = TextUnderlineType.Single;
portionBold.PortionFormat.FillFormat.FillType = FillType.Solid;
portionBold.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

IPortion portion3=new Portion();
portion3.Text=st3;
portion3.PortionFormat.FillFormat.FillType = FillType.Solid;
portion3.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

//Now adding para to portions
para.Portions.Add(portionBold);
para.Portions.Add(portion3);

pres.Save(“D:\Aspose Data\TestText.pptx”, SaveFormat.Pptx);

Many Thanks,