Free Support Forum - aspose.com

Text added to TextFrame.Paragraph.Portion gets auto justified/Word breaking . Slide is Multi Paragraphedes

I am constructing a Multi-Paragraphs slide using Text Frame.Paragraph.Portion. I am able to produce the slide without any issue but Text within Paragraphs by default getting Auto Justified or not properly line breaking i.e. word breaks happening. I don’t want Auto Justified or word breaking in text lines of paragraph. I have tried using option para.ParagraphFormat.Alignment = TextAlignment.Left but nothing happens. I am using latest Aspose.Slides.DLL with trial license. Can you give me some tip by which I am able to show text lines without breaking word in next line?

Hi Mohit,

Thanks for your growing interest in Aspose.Slides.

I have observed your requirements and request you to please provide the working sample code, generated presentation and desired output presentation whereby you want text to appear in desired manner. I will be able investigate the requirements on my end once the requested information will be shared. Moreover, you can get our free 30 days license for evaluation of product on your end. Please follow these guidelines for availing temporary license.

Many Thanks,

Below is the code that I am using to produce the attached .PPTX slide screenshot. I have highlighted the words that are broken in the final output. I want that words should not break while text get wrapped or shifted in Next line in text frame.Paragraph.Portion.

Public Sub setLeftSide1(ByRef tf As ITextFrame)
Dim paranum As Integer
Dim portionnum As Integer
Dim portio As New Portion
paranum = 0
tf.Text = ""
tf.Paragraphs.Clear()

portionnum = 0
Dim para As IParagraph = New Paragraph
Dim port As IPortion = New Portion
Dim port2 As IPortion = New Portion
para.ParagraphFormat.Indent = 0.0
para.Portions.Add(port)
tf.Paragraphs.Add(para)
tf.Paragraphs(paranum).Portions(portionnum).Text = "This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly"

port2 = tf.Paragraphs(paranum).Portions(portionnum)

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.LatinFont = New FontData("Arial Narrow")
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.FillType = FillType.Solid
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.SolidFillColor.Color = Color.Black
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FontHeight = fontsize
End Sub

Hi Mohit,

I have observed your requirement and like to share that you need to set the text alignment for paragraph in your text frame. Please try using following sample code on your end to serve the purpose.

Public Shared Sub TestTex(tf As ITextFrame)
Dim paranum As Integer = 0
Dim portionnum As Integer = 0
Dim portio As New Portion()
paranum = 0
tf.Text = “”
tf.Paragraphs.Clear()

portionnum = 0
Dim para As IParagraph = New Paragraph()
Dim port As IPortion = New Portion()
Dim port2 As IPortion = New Portion()
’ para.ParagraphFormat.Indent = 0.0;
para.Portions.Add(port)
tf.Paragraphs.Add(para)
tf.Paragraphs(paranum).Portions(portionnum).Text = “This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly”

port2 = tf.Paragraphs(paranum).Portions(portionnum)

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.LatinFont = New FontData(“Arial Narrow”)
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.FillType = FillType.Solid
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.SolidFillColor.Color = Color.Black
tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FontHeight = 14

tf.TextFrameFormat.WrapText = NullableBool.[True]
para.ParagraphFormat.Alignment = TextAlignment.Justify
End Sub

Many Thanks,

Mudassir,


Thanks for your quick reply. I applied the changes suggested by you but still facing the same issue i.e. words are breaking.


Mudassir,


I forgot to mention the code. Changes suggested by you are applied at the end (highlighted in yellow) in below sub.

Public Sub setLeftSide1(ByRef tf As ITextFrame)<o:p></o:p>

Dim paranum As Integer

Dim portionnum As Integer

Dim portio As New Portion

paranum = 0

tf.Text = ""

tf.Paragraphs.Clear()

portionnum = 0

Dim para As IParagraph = New Paragraph

Dim port As IPortion = New Portion

Dim port2 As IPortion = New Portion

para.ParagraphFormat.Indent = 0.0

para.Portions.Add(port)

tf.Paragraphs.Add(para)

tf.Paragraphs(paranum).Portions(portionnum).Text = "This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly"

port2 = tf.Paragraphs(paranum).Portions(portionnum)

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.LatinFont = New FontData("Arial Narrow")

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.FillType = FillType.Solid

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.SolidFillColor.Color = Color.Black

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FontHeight = fontsize

tf.TextFrameFormat.WrapText = NullableBool.True

para.ParagraphFormat.Alignment = TextAlignment.Justify

End Sub

Hi Mohit,


I have observed your comments and it is not getting evident if the issue is still incurring or resolved on your end after suggested modifications. If there is still an issue, can you please share working sample project, source presentation and generated presentation so that we can further investigate to help you out. Also please share try using Aspose.Slides for .NET 17.4 on your end if you are using some older version.

Best Regards,

Hi Adnan,

I have not created any sample project separately. For sending the details of my case I just modified the existing code within my big project and produced the sample PPTXs attached for your reference. In order to give more clarity of my case I am forwarding you following

• Source code showing slide generation from start to end within my code

------------------------------------------

'Starting Point for PPTX generation

Public Sub New(ByVal proj As Integer)

pres = New Presentation()

'Create a License object

Dim license As License = New License()

'Set the license of Aspose.Slides for .NET

license.SetLicense(“Aspose.Slides.lic”)



generateSlide(pres)

End Sub

'Generate Slide function creates Clone of desired PPTX template file and start the process of filling text in the slides

Protected Sub generateSlide(ByRef pres As Presentation) 'Replaced Protected Sub generateSlide(ByRef pres As PresentationEx)

Dim templatelocation As String



pres.SlideSize.Orientation = SlideOrienation.Landscape



pres.SlideSize.SetSize(SlideSizeType.Custom, SlideSizeScaleType.DoNotScale)

'Get template

templatelocation = AppSettings(“templateLocation”)

Dim templatePres As Presentation = New Presentation(templatelocation)

Dim templateSlide As ISlide

templateSlide = templatePres.Slides(0)



pres.Slides.AddClone(templateSlide)



pres.Slides.RemoveAt(0)



Dim slide As ISlide = pres.Slides(0)



'Set the text

setText(slide)



End Sub

'This function simply set the text in the desired place by simply checking shapes (included in slide from given template file)

Public Sub setText(ByRef slide As ISlide)

Dim i As Integer

Dim th As ITextFrame

Dim thText As String

Dim shp As IShape

For i = 0 To slide.Shapes.Count - 1

shp = slide.Shapes(i)

Dim mytext As String

If (TypeOf shp Is IAutoShape) Then

If Not (CType(shp, IAutoShape).TextFrame Is Nothing) Then

Dim ashp As IAutoShape = CType(shp, AutoShape)

Dim tframe As ITextFrame = ashp.TextFrame

mytext = tframe.Text

If mytext = “Leftside Text” Then

setLeftSide1(tframe)

End If

End If

End If

Next

End Sub

'Fill the text in LeftSide Text frame

Public Sub setLeftSide1(ByRef tf As ITextFrame)

Dim paranum As Integer

Dim portionnum As Integer

Dim portio As New Portion

paranum = 0

tf.Text = “”

tf.Paragraphs.Clear()



portionnum = 0

Dim para As IParagraph = New Paragraph

Dim port As IPortion = New Portion

Dim port2 As IPortion = New Portion

para.ParagraphFormat.Indent = 0.0

para.Portions.Add(port)

tf.Paragraphs.Add(para)

tf.Paragraphs(paranum).Portions(portionnum).Text = “This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly”



port2 = tf.Paragraphs(paranum).Portions(portionnum)



tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.LatinFont = New FontData(“Arial Narrow”)

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.FillType = FillType.Solid

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FillFormat.SolidFillColor.Color = Color.Black

tf.Paragraphs(paranum).Portions(portionnum).PortionFormat.FontHeight = fontsize

tf.TextFrameFormat.WrapText = NullableBool.True

para.ParagraphFormat.Alignment = TextAlignment.Justify

End Sub

---------------------------------------

• PPTX Template file

• Actual .PPTX file generated from the attached code - (Aspose Test.pptx)

• ASPOSE.Slides.DLL Version details - (AsposeSlidesDLL.png)

Hope above information will give more clarity of my case.

If the info provided by me doesn’t help then I would like to request you to please try to create a simple slide on your end try to fit the following long text in text frame and if your slide is generated without improper work breaking on next line then please do send me that code. I will try that code in my project.

”This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly.This is a long text no fitting properly”

Hi Mohit,

Attached please find the working sample project that I have created using Aspose.Slides for .NET 17.4.0 by employing your code in it. I have not been able to observe issue of text breaking on my end and for your kind reference, the generated presentation is also attached along with this snapshot link. Can you please try using the attached sample project and observe the generated presentation for your reference.

Many Thanks,

Thank you very much for sending me the sample project along with the latest Aspose.Slides.DLL version 17.4.0.0. After using this DLL in my Project the issue of Word breaking on next line got fixed.

Hi Mohit,

It’s good to know things are resolved on your end. Please share, if I may be of any further help to you in this regard.

Many Thanks,