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

Free Support Forum - aspose.com

Tight Deadline- NewLine rendering Issues in Paragraph

Hello!

I hope you are doing well!

This post with reference to the difference in rendering newlines when we change the SpaceBefore and SpaceAfter properties of the Paragraph. To illustrate this, I want to share two examples and their corresponding outputs:
Please notice that in the second example, I have just added the following lines:
somePara.ParagraphFormat.SpaceBefore = -3.5f;
somePara.ParagraphFormat.SpaceAfter = -3.5f;

Now, since SpaceBefore specifies the space before the first line of the Paragraph and SpaceAfter specifies the space after last line in the paragraph, there shouldn’t be a difference inside the paragraph itself, but as we can see, the line height of new line is higher in the second paragraph.

Please help me. I want -3.5 before and after the paragraph and no extra space after the newline (I want the way it is rendering in the first example but with spacebefore and spaceafter). Thanks in advance!

Example1:

code:
m_secondPresentation = new Presentation();
var autoShape = m_secondPresentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, m_secondPresentation.SlideSize.Size.Width, m_secondPresentation.SlideSize.Size.Height);
autoShape.UseBackgroundFill = true;
autoShape.AddTextFrame("");
autoShape.UseBackgroundFill = true;
var frame = autoShape.TextFrame;
var somePara = new Paragraph();
var portion1 = new Portion(“this is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some text”);
var portion2 = new Portion("\n");
var portion3 = new Portion(“this is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another line”);
somePara.Portions.Add(portion1);
somePara.Portions.Add(portion2);
somePara.Portions.Add(portion3);
somePara.ParagraphFormat.SpaceWithin = -12.0f;
frame.Paragraphs.Add(somePara);
string path = @"…";
m_secondPresentation.Save(path,SaveFormat.Pptx);

Output1:
Example-1.PNG (10.5 KB)

Example 2:

Code:
m_secondPresentation = new Presentation();
var autoShape = m_secondPresentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 0, 0, m_secondPresentation.SlideSize.Size.Width, m_secondPresentation.SlideSize.Size.Height);
autoShape.UseBackgroundFill = true;
autoShape.AddTextFrame("");
autoShape.UseBackgroundFill = true;
var frame = autoShape.TextFrame;
var somePara = new Paragraph();
var portion1 = new Portion(“this is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some textthis is some text”);
var portion2 = new Portion("\n");
var portion3 = new Portion(“this is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another linethis is yet another line”);
somePara.Portions.Add(portion1);
somePara.Portions.Add(portion2);
somePara.Portions.Add(portion3);
somePara.ParagraphFormat.SpaceBefore = -3.5f;
somePara.ParagraphFormat.SpaceAfter = -3.5f;
somePara.ParagraphFormat.SpaceWithin = -12.0f;
frame.Paragraphs.Add(somePara);

        string path = @".....";
        m_secondPresentation.Save(path,SaveFormat.Pptx);

Example-2.PNG (10.5 KB)

@rajatfds,

I have observed your comments. Can you please share generated result with us so that we may further investigate to help you out.

Presentations.zip (56.1 KB)
Hi Adnan,

Thank you for youre reply!

Please find the presentations attached here. That of sample one by the name Pres-1 and similar for sample-2.

Looking forward to hear from you!!

Thanks,
Rajat!

@rajatfds,

I have worked with source code shared by you using Aspose.Slides for .NET 17.7 and have been able to observe the issue. A ticket with ID SLIDESNET-39187 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.

We are sorry for your inconvenience,