Text Inside a TextFrame Becomes Bold

After I replaced part of the text (last line) inside a TextFrame, the font size changed and the text becomes bold even though I did not change any of the formatting or style. I used Powerpoint 2007 and Aspose.Slides.Pptx for this demonstration. Attached are the input pptx template and the output file.
I used Aspose.slides.dll version 4.1.1.0. Question: why the text (last line) becomes bold and font size changed in the output file?

Below is the code I used:

Imports Aspose.Slides.Pptx
Private Sub test_TextFrame()
Dim pres As Aspose.Slides.Pptx.PresentationEx
Dim pptxFile As String = “…/…/Test_TextFrame.pptx”
Dim outputFile As String = “…/…/output.pptx”
pres = New Aspose.Slides.Pptx.PresentationEx(pptxFile)
For Each sl As SlideEx In pres.Slides
For Each sh As ShapeEx In sl.Shapes
If sh.AlternativeText.Length > 0 Then
Dim txFrame As TextFrameEx = CType(sh, AutoShapeEx).TextFrame
If txFrame.Text.Contains("@@TotaSalesInBillions") Then
txFrame.Text = txFrame.Text.Replace("@@TotaSalesInBillions", “10.0”)
End If
End If
Next
Next

pres.Write(outputFile)
End Sub

It looks like there is an issue with how underlined text is handled.

I added one more line to the TextFrame to test what happens the underlined text. The underline does not show up in the output. Please see the input template, Test_TextFrame.pptx, and output.pptx.

The same test program above was used.

Hi,

I have worked on the shared presentation files along with the problematic output presentation. I feel there is some problem in the code snippet. Actually, when you set tex on text frame level, the font related properties are set to default. In order to preserve those properties, you please do text replacement on text portion level. I have modified your code snippet and shared modified one. I have verified proper functioning of both of your presentations.

Private Sub test_TextFrame()

Dim pres As Aspose.Slides.Pptx.PresentationEx

Dim pptxFile As String = "D:/ppt/Test_TextFrame.pptx"

Dim outputFile As String = "D:/ppt/TextFrame_output.pptx"

pres = New Aspose.Slides.Pptx.PresentationEx(pptxFile)

For Each sl As SlideEx In pres.Slides

For Each sh As ShapeEx In sl.Shapes

If sh.AlternativeText.Length > 0 Then

Dim txFrame As TextFrameEx = CType(sh, AutoShapeEx).TextFrame

For Each Para As ParagraphEx In txFrame.Paragraphs

For Each Portion As PortionEx In Para.Portions

If Portion.Text.Contains("@@TotaSalesInBillions") Then

Portion.Text = Portion.Text.Replace("@@TotaSalesInBillions", "10.0")

End If

Next

Next

End If

Next

Next

pres.Write(outputFile)

End Sub

Thanks and Regards,

This works fine. Thank you very much.