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

Free Support Forum - aspose.com

Different line spacing

Hello,

I have two PowerPoint files.zip (44.6 KB) that I produce with Aspose slides. Both contain exactly the same shape with two lines of text “AAA\r(123)”.
In 1.pptx the text cannot fit in the shape while in 2.pptx everything is OK. Looks like the line spacing is different, but it is not…
Interesting thing is that if I’ll copy one shape (with text) form first file to the second, then the shapes are adapting to the style of the second presentation.

It seems that there is a setting in presentation level that is different on those two files.
Can you please help?

Kind regards,
FB

@fireball4,

I have observed the issue shared by you and request you to please share the sample code and source file (if any) reproducing the issue on your end. Please share the requested information so that we may help you further in this regard.

Hey,
Sorry for the late response. You can find what you asked here (71.5 KB).

@fireball4,

I have worked with the source project shared by you and have been able to observe the issue. An issue with ID SLIDESNET-41748 has been created in our issue tracking system to further investigate the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hello @mudassir.fayyaz,
Is there any update on that issue? I retest it with version 20.3 and it is still there.
Thank you,
FB

@fireball4,

I have verified the issue status from our issue tracking system and like to share it is going to be resolved in upcoming Aspose.Slides for .NET 20.4. The difference between your source presentations and the new presentation created by Aspose.Slides is “before spacing” for the same level paragraphs. You can check it using the following code snippet:

using (var presentation = new Presentation(path + "Test.pptx"))
{
    // get presentation paragraph format for first level paragraphs
    IParagraphFormat paraFormat = presentation.DefaultTextStyle.GetLevel(0);
    Console.WriteLine("Test.pptx paragraph Before Space: " + paraFormat.SpaceBefore); // 50%
}

using (var presentation = new Presentation(path + "Test2.pptx"))
{
    // get presentation paragraph format for first level paragraphs
    IParagraphFormat paraFormat = presentation.DefaultTextStyle.GetLevel(0);
    Console.WriteLine("Test2.pptx paragraph Before Space: " + paraFormat.SpaceBefore); // 50%
}

using (var presentation = new Presentation())
{
    // get presentation paragraph format for first level paragraphs
    IParagraphFormat paraFormat = presentation.DefaultTextStyle.GetLevel(0);
    Console.WriteLine("New presentation paragraph Before Space: " + paraFormat.SpaceBefore); // NaN - not set
}

So in first case you add the new shape to “Test.pptx” and it use ParagraphFormat.SpaceBefore = 50.
And in second case the shape is added to the new presentation and it use the default value of ParagraphFormat.SpaceBefore = 0.

To avoid using values from presentation level, you can set values for shape:

private static void AddInnerText(IAutoShape shape)
{
    shape.TextFrame.TextFrameFormat.AutofitType = TextAutofitType.None;
    shape.TextFrame.TextFrameFormat.WrapText = NullableBool.False;

    IParagraphFormat paraFormat = shape.TextFrame.Paragraphs[0].ParagraphFormat;
    paraFormat.SpaceBefore = 0;
    paraFormat.SpaceAfter = 0;

    IPortionFormat portionFormat = paraFormat.DefaultPortionFormat;
    portionFormat.FontHeight = 7;
    portionFormat.FillFormat.FillType = FillType.Solid;

    shape.TextFrame.Text = "AAA\r(123)";
}

Or it possible to reset values on presentation level:

private static void CreateFirstPresentation()
{
    using (var presentation = new Presentation(path + "Test.pptx"))
    {
        ResetPresentationParagraphFormat(presentation);

        presentation.Slides.RemoveAt(0);
        presentation.Slides.AddEmptySlide(presentation.LayoutSlides.First());

        AddShape(presentation.Slides[0]);
        presentation.Save(path + "first.pptx", SaveFormat.Pptx);
    }
}

private static void ResetPresentationParagraphFormat(IPresentation presentation)
{
    int levels = 9; // default count of text style levels

    for(int i = 0; i < levels; i++)
    {
        IParagraphFormat paraFormat = presentation.DefaultTextStyle.GetLevel(i);
        if(paraFormat != null)
        {
            paraFormat.SpaceBefore = 0; // 0%
            paraFormat.SpaceAfter = 0; // 0%
            paraFormat.SpaceWithin = 100; // 100%
            //...
        }
    }
}

Thank you! That was really helpful!

The issues you have found earlier (filed as SLIDESNET-41748) have been fixed in this update.