facebooktwittermenuarrow-up

GemBox Support Forum

Create image of each slide

I have a PowerPoint with 50 slides. What I need to do is produce 50 images (jpeg) - one per slide. All I can do so far is get the first slide as an image.

Can you please help?

Hi Greg,

Try this:

var presentation = PresentationDocument.Load("input.pptx");
var imageOptions = new ImageSaveOptions(ImageSaveFormat.Png);

for (int i = 0; i < presentation.Slides.Count; i++)
{
    imageOptions.SlideNumber = i;
    presentation.Save($"slide_{i + 1}.png", imageOptions);
}

Does this solve your issue?

Regards,
Mario

Yes it does - thank you. However what I see in Powerpoint is not what I am getting when I render the image in jpeg or png format. Objects and shapes are missing. Can you please review the attached screenshot and update me on what the problem is??

Hi Greg,

I’m afraid I cannot investigate the screenshot…

Nevertheless, it seems that those triangle shapes are not of a supported shape type or perhaps they are not a supported element type.

Anyway, to tell you anything for sure, I would need to investigate your presentation.

Regards,
Mario

Thanks Mario. I have emailed you the template.

Hi Greg,

Your slide contains a Picture Placeholder with custom geometry.

I’m afraid that Shapes with custom geometry are currently only supported through preservation (when loading from and saving to the same PPTX format).

Regards,
Mario

Oh no - that is a showstopper for me. Can you suggest any alternatives to be able to output accurate slide images?

Hi,

The only workaround that comes to my mind is to use the image that originally looks like that.
In other words, the image data itself has that customized triangle pattern.

Regards,
Mario

That is not going to work. Without the custom geometry being supported it throws out the layout of other shapes in the image.

I did test manually ‘exporting’ the images from PowerPoint and it works fine there. However I need an automated solution.

Hi,

Apologize for the inconvenience.

I’m afraid this feature is not in our current roadmap so it won’t be available this year, for later I cannot say at this moment.

Please note that we priorities feature request implementations by the number of users requesting them and currently we are working on some other features that have greater priority (more user requests).

Regards,
Mario

By using the interop libraries it works for me and I get a correct image. Can you think of any downfall with this approach?

Microsoft.Office.Interop.PowerPoint.Application powerPoint = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentation ppt = null;

try
{
    ppt = powerPoint.Presentations.Open("c:\\temp\\" + siteName + "\\output3.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

    for (int i=1; i <= SlideCounter; i++)
    {
        ppt.Slides[i].Export("c:\\temp\\" + siteName + "\\outputimages\\slide_" + i + ".png", "png", 800, 450);
    }

    ppt.Close();
    Marshal.FinalReleaseComObject(ppt);
}
catch (Exception ex) { }
finally
{
    powerPoint.Quit();
    Marshal.FinalReleaseComObject(powerPoint);
    GC.Collect();
    GC.WaitForPendingFinalizers();
}

Hi,

The downfall is that you have a dependency to Microsoft PowerPoint. In other words, machines that are working on developing your application and the machines that are executing your application will need to have Microsoft Office install.

Besides that I don’t see any problems here.

Regards,
Mario