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

Free Support Forum - aspose.com

Portions font properties are not being assigned in Aspose.Slides.NET

Portions font properties are not being assigned in Aspose.Slides for .NET, except those that are boolean.
I show the code next:

Aspose.Slides.Rectangle shapeTxtRTF = slide.Shapes.AddRectangle(0, 0, 500, 300);
LineFormat llRTF = shapeTxtRTF.LineFormat;
llRTF.ShowLines = false;
TextFrame tfRTF = shapeTxtRTF.AddTextFrame(string.Empty);

System.Drawing.Font oldFont = richTextBox.SelectionFont;
Color oldColor = richTextBox.SelectionColor;

for (int itt = 0; itt < richTextBox.Lines.Length; itt++)
richTextBox.Select(richTextBox.GetFirstCharIndexFromLine(itt), richTextBox.Lines[itt].Length);
if (richTextBox.Lines[itt].Length > 0)
oldFont = richTextBox.SelectionFont;
oldColor = richTextBox.SelectionColor;
Aspose.Slides.Paragraph para = new Aspose.Slides.Paragraph();
para.Text = richTextBox.Lines[itt];
para.Portions[0].FontBold = oldFont.Bold;
para.Portions[0].FontItalic = oldFont.Italic;
para.Portions[0].FontHeight = (short)oldFont.Size;
para.Portions[0].FontColor = oldColor;
para.Portions[0].FontUnderline = oldFont.Underline;
tfRTF.WrapText = true;
tfRTF.FitShapeToText = true;

The strange thing is that even if I hardcode a value the portion is not taking the font non-boolean values, even when debugging (and using watches).
Any help will be appreciated.
Thank you and best regards!

Hi Mariano,

Thanks for your interest in Aspose.Slides.

The code snippet shared by you seems to be fine but I am unable to reproduce your code. However, based on the code snippet shared by you, I have been able to generate a working code and I have tested that using Aspose.Slides for .NET 4.4.0. Can you please share, which version of Aspose.Slides for .NET you are using. The version you have shared doesn't exisit.

Presentation presnew = new Presentation();

Slide sld = presnew.Slides[0];

Aspose.Slides.Rectangle rect = sld.Shapes.AddRectangle(200, 330, 700, 900);

TextFrame th = rect.AddTextFrame(" ");


Paragraph pg = new Paragraph();


Portion pr = new Portion();


pr.FontBold = true;

pr.FontHeight = 22;

pr.FontColor = Color.Blue;

pr.FontItalic = true;

pr.FontShadow = true;

pr.Text = "Hello World";


Thanks and Regards,

I’m using file version with a product version of 2008.10.12, and portion.FontItalic = True is simply not working. portion.FontEmbossed = True is actually killing all other formatting and portion.Shadow is ignored as well. I really need italics inside of a paragraph. Following is my code. I’ve tried assigning the FontItalic property before and after every single statement inside my loop.

Dim par As Paragraph = tFrame.Paragraphs(0)
Dim findex As Integer = par.Portions(0).FontIndex
For Each field As String In expitem.GetFields()
Dim portion As Portion = par.Portions(0)
Dim style As ExpStyleName = expitem.GetStyles(field)
newPPT.Fonts(findex).FontName = “Helvetica”
portion.FontHeight = 10
par.Alignment = TextAlignment.Center
If style = ExpStyleName.Header Then
portion.FontBold = NullableBool.True
ElseIf style = ExpStyleName.Emphasis Then
portion.FontItalic = NullableBool.True
portion.FontColor = Color.Blue
End If
portion.Text = StripHtml(expitem.GetValue(dr, field))
par = New Paragraph()
par.Portions.Add(New Portion())

Hi Mariano,

I have tested the code snippet shared by you and it worked fine on my end. I would suggest that you may please use Aspose.Slides for .NET 5.6.0 and if the issue still persist then please share a sample project code and output presentation to further investigate the issue.

Many Thanks,