C # realizes the process of converting each page of PPT into pictures


To convert PPT to picture, you first need to reference two DLLs.

I use this version here

  • Microsoft.Office.Interop.PowerPoint 12.0
  • Microsoft Office 12.0 object Library

As shown below:

The code is as follows:

private void pptToImg(string pptPath, string imgPath)
      var app = new Microsoft.Office.Interop.PowerPoint.Application();

      var ppt = app.Presentations.Open(pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);

      var index = 0;

      var fileName = Path.GetFileNameWithoutExtension(pptPath);

      foreach (Microsoft.Office.Interop.PowerPoint.Slide slid in ppt.Slides) 
        //Set picture size
        slid.Export(imgPath+string.Format("page{0}.png",index.ToString()), "png", 1024, 768);
        //According to the screen size. Set picture size
        //slid.Export(imgPath+string.Format("page{0}.jpg",index.ToString()), "jpg", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

      //Release resources

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.

Recommended Today

Implementation example of go operation etcd

etcdIt is an open-source, distributed key value pair data storage system, which provides shared configuration, service registration and discovery. This paper mainly introduces the installation and use of etcd. Etcdetcd introduction etcdIt is an open source and highly available distributed key value storage system developed with go language, which can be used to configure sharing […]