How custom resolution supported in .NET WebForms PowerPoint slide to image conversion?
You can improve the image quality by providing custom image resolution while conversion.
The following code snippet demonstrates how to convert Presentation slides to images with custom image resolution.
C#
//Opens a PowerPoint presentation IPresentation presentation = Presentation.Open("../../Data/SlidesSample.pptx"); //Iterates through the slide collection to convert as image foreach (ISlide slide in presentation.Slides) { //Converts the slide as image Image image = slide.ConvertToImage(Syncfusion.Drawing.ImageType.Bitmap); //Creates a bitmap of specific width and height Bitmap bitmap = new Bitmap((int)((image.Width * 500) / 96.0f), (int)((image.Height * 500) / 96.0f), PixelFormat.Format32bppPArgb); //Sets the resolution bitmap.SetResolution(500, 500); //Gets graphics from the custom size bitmap image Graphics graphics = Graphics.FromImage(bitmap); //Recreate the image from stream using specified width and height graphics.DrawImage(image, new Rectangle(0, 0, bitmap.Width, bitmap.Height)); //Saves the image image.Save("ImageOutput" + Guid.NewGuid().ToString() + ".jpeg"); } //Closes the presentation presentation.Close();
VB.NET
'Opens a PowerPoint presentation Dim presentationDocument As IPresentation = Presentation.Open("../../Data/Test1.pptx") 'Iterates through the slide collection to convert as image For Each slide As ISlide In presentationDocument.Slides 'Converts the slide as image Dim image As Image = slide.ConvertToImage(Syncfusion.Drawing.ImageType.Bitmap) 'Creates a bitmap of specific width and height Dim bitmap As New Bitmap(CInt((image.Width * 500) / 96.0F), CInt((image.Height * 500) / 96.0F), PixelFormat.Format32bppPArgb) 'Sets the resolution bitmap.SetResolution(500, 500) 'Gets graphics from the custom size bitmap image Dim gdiGraphics As Graphics = Graphics.FromImage(bitmap) 'Recreate the image from stream using specified width and height gdiGraphics.DrawImage(image, New Rectangle(0, 0, bitmap.Width, bitmap.Height)) 'Saves the image image.Save("ImageOutput" + Guid.NewGuid().ToString() + ".jpeg") Next 'Closes the presentation presentationDocument.Close()
Sample Link - https://www.syncfusion.com/downloads/support/directtrac/172771/ze/Sample-1665031271
Note:
A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions. The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.
The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.
You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!