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:
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.
|
//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(); |
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!