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

Free Support Forum - aspose.com

How to Reduce Height and Width of Slides when Converting a Presentation to HTML?

Hi,
Is it possible to reduce the height and width of each slides before a presentation file is converted to an html ?

@pooja.jayan,
Thank you for your question.

To reduce the height and width of each presentation slide, you can change the slide size as shown below:

var scaleValue = 0.5f;
using (var presentation = new Presentation("example.pptx"))
{
    var slideSize = presentation.SlideSize.Size;
    var newSize = new SizeF(slideSize.Width * scaleValue, slideSize.Height * scaleValue);

    presentation.SlideSize.SetSize(newSize.Width, newSize.Height, SlideSizeScaleType.EnsureFit);
    presentation.Save("output.html", SaveFormat.Html);
}

Alternatively, you can scale the output HTML content like this:

var htmlOptions = new HtmlOptions
{
    HtmlFormatter = HtmlFormatter.CreateCustomFormatter(new ScaleHtmlController())
};

using (var presentation = new Presentation("example.pptx"))
{
    presentation.Save("output.html", SaveFormat.Html, htmlOptions);
}
class ScaleHtmlController : IHtmlFormattingController
{
    public void WriteDocumentStart(IHtmlGenerator generator, IPresentation presentation)
    {
    }

    public void WriteDocumentEnd(IHtmlGenerator generator, IPresentation presentation)
    {
    }

    public void WriteShapeEnd(IHtmlGenerator generator, IShape shape)
    {
    }

    public void WriteShapeStart(IHtmlGenerator generator, IShape shape)
    {
    }

    public void WriteSlideStart(IHtmlGenerator generator, ISlide slide)
    {
        generator.AddHtml(m_slideStart);
    }

    public void WriteSlideEnd(IHtmlGenerator generator, ISlide slide)
    {
        generator.AddHtml(m_slideEnd);
    }

    private const string m_slideStart = "<div style=\"zoom: 0.5; -moz-transform: scale(0.5);\">\n";
    private const string m_slideEnd = "</div>\n";
}

Documents:
Slide Size
Convert PowerPoint (PPT, PPTX) to HTML

API Reference:
ISlideSize interface
HtmlOptions class
HtmlFormatter class
IHtmlFormattingController interface

1 Like