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

Free Support Forum - aspose.com

Unable to assign font properties to a portion which is part of a paragraph that contains existing portions with different formatting

I am unable to set properties such as FontBold, FontItalic, etc on portions that are a part of a Paragraph that contains existing Portions. The members are marked as RW, however they cannot be set.

Here's an example:

Dim tCell As Cell
Dim tPara As Paragraph = New Paragraph
Dim tPort As Portion = New Portion
tPort.FontBold = False
tPort.Text = "Hello"
tPort = New Portion
tPort.FontBold = True
tPort.Text = " World!"

In this example, "Hello" will not be bold (as expected), but "World!" will not be bold either. If this is by design, then what is the point of having 'portions' which are defined in the Aspose.Slides documentation as segments of a line(Paragraph) with different formatting?


You should add Portion to a Paragraph and Paragraph to a TextFrame (Cell in you case) and only after that change properties.

Just to clarify, add the set portion.text, then add portion to paragraph, and paragraph to cell.textframe, THEN modify the font properties of the portion?

Yes, that is correct.

Ok I will give that a shot then.

I'm just curious now, is this by design? I think it'd make more sense to be able to modify font properties of a portion at the same time you're adding text, etc. Rather than having to go back after adding Text, etc, and select it from the paragraph.portions() array.

Alright, so this isn't working either.

I am doing the following:

1)creating a new portion

2)changing portion.text

3)then adding that portion to a paragraph (along with other portions)

4)saving location of the portion so I can refer back to it to change font properties

5)adding paragraph to a textbox

6)doing: textbox.paragraphs(count-1).portions(savedLocation).fontBold = true

7)fontBold is still false after setting to true, no font properties are saved in the portion.

Attached is the code for the function. The function takes a string of html tags and text, and formats the portions of text according to the html tag they lie within.

  1. Why you need all these ArrayLists?
    2. For i As Integer = 0 To (htmlStringArray.Length - 1) definitely won’t work because logic is wrong. You set font properties for empty portions. For the portion with text no font properties are applied. Try to run this code in debugger and check how it works.

    I have changed the function to give the idea how to set properties. Anyway, you probably have to change html parsing code to make it work.

1. Yes I understand I didn't need them. After I posted the attachment in my previous mail, I revised the function to remove the unnecessary arrays.

2. This For loop was for an array of strings to process, not for an array of portions.

So ultimately I need to have an array of paragraphs (paras in your revision) to add paragraphs to, instead of directly to the textframe? Sorry if it seems like I'm clueless, the documentation for modifying multiple portions in a single paragraph, and multiple paragraphs in a textframe does not exist (at least I've not been able to locate any)


The documentation has been updated and your desired topic has been added here.



The documentation has been updated and your desired topic has been added here.

I just read over it, definitely clears up any confusion I had. Nice work, thanks!


Thanks suggesting the said topic. We always look for improvements.