Spire.PDF is an easy-to-use and powerful .NET PDF library. It can do a lot of conversions, and one of them is converting PDF page to image. As to converting PDF page to image, it works conveniently and flexibly. It has 6 overloaded functions named SaveAsImage that can make sure you find one meeting your need.
You can use Spire.PDF to convert any specific page of PDF document to BMP and Metafile image. Check it here.
In this article, we will discuss conversion with specified resolution.
[C#]
public Image SaveAsImage(int pageIndex, int dpiX, int dpiY)
- pageIndex: specify which page to convert, 0 indicates the first page.
- dpiX: specify the resolution of x coordinate axis in PDF page when converting.
- dpiX: specify the resolution of y coordinate axis in PDF page when converting.
[C#]
Image image = documemt.SaveAsImage(0, PdfImageType.Bitmap, false, 400, 400)
In the sample code, the size of PDF page is Width = 612.0, Height = 792.0. We set the resolution to 400, 400. And we will get an image with width = 3400, height = 4400.
Here is sample code:
[C#]
PdfDocument documemt = new PdfDocument(); documemt.LoadFromFile(@"..\..\EnglishText.pdf"); Image image = documemt.SaveAsImage(0, PdfImageType.Bitmap, false, 400, 400); image.Save(@"..\..\result.jpg"); documemt.Close();
Effect Screentshot: