Unable to Set the Multiple Line Spacing Options for a Text Part or Paragraph

Hi,

I am working on creating a textbox in a presentation. Although I can create the text box shapes and add the paragraph, when I go to add the text, the lines are spaced by default at single space. However, I would like them to be a bot closer than a full line.

In PowerPoint, I can change the settings to this:

Presentation Line Spacing.png

Although I can access the "Before" and "After" options, these are just for the spacing before and after the paragraph. I want to be able to change the spacing for the text part itself, making use of the "Line Spacing " options (as seen in the picture above). But I am unable to find the objects or setting for these through the Presentation code.

Any help or information would be appreciated.


3 Replies

LB Lokesh Baskar Syncfusion Team October 19, 2021 02:20 PM UTC

Hi Edward,

Thank you for contacting Syncfusion support.

On further analysis, we have found that when we set LineSpacing value to the paragraph by default the LineSpacing is set as “Exactly”. The LineSpacing value is work similar to the “Exactly” in Syncfusion Presentation library.  So, it not feasible to set the LineSpacing as Single, Double or Multiple using Syncfusion Presentation.
 
 
As a workaround solution we can set the line spacing value which is equivalent to “Multiple” by checking the value using Microsoft PowerPoint. 
//Creates PowerPoint Presentation 
IPresentation pptxDoc = Presentation.Create(); 
 
//Adds slide to the PowerPoint 
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); 
 
//Adds textbox to the slide 
IShape textboxShape = slide.AddTextBox(0, 0, 500, 500); 
 
//Adds paragraph to the textbody of textbox 
IParagraph paragraph = textboxShape.TextBody.AddParagraph(); 
 
paragraph.LineSpacing = 65; 
paragraph.SpaceAfter = 0; 
paragraph.SpaceBefore = 0; 
 
//Adds a TextPart to the paragraph 
ITextPart textPart = paragraph.AddTextPart(); 
 
//Adds text to the TextPart 
textPart.Text = "AdventureWorks Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Washington with 290 employees, several regional sales teams are located throughout their market base."; 
 
//Save the PowerPoint Presentation as stream 
MemoryStream outputStream = new MemoryStream(); 
pptxDoc.Save(outputStream); 
 
//Closes the Presentation 
pptxDoc.Close(); 


Please let us know if you have another query.

Regards,
 
Lokesh B 



EW Edward Williams October 19, 2021 02:29 PM UTC

Looks like that will do the trick.

So, the Line Spacing represents the number of points for the spacing under the "Exactly" option.

I had to tweak the 65 in your example to 18 to get what I was looking for, But it works.

Thanks for your help!



LB Lokesh Baskar Syncfusion Team October 20, 2021 07:22 AM UTC


Loader.
Up arrow icon