PDF, short for Portable Document Format, is one of the most popular file formats that could include and present text, fonts, graphics, and more on application operating systems, software, even on hardware which supports document presentation. It is also one of document formats that could be read directly by most popular desktop web browsers. A large amount of data is held by PDF on the Internet.
How to Convert PDF to PNG
The popularity of PDF file format is undeniable. However, in some circumstances, PDF file format is not suitable to accomplish task in .NET programming and you may need to change a large amount of pages in PDF document into .png image files. If so, why not try our PDF to Image Converter Library for .NET free testing package, the complete and affordable solution for your application. On this tutorial, you will know how to easily convert PDF into PNG images.
PNG, Portable Network Graphics, refers to a raster graphics file format, which was created to replace GIF (Graphics Interchange Format) image format. PNG image supports lossless data compression, and it is the most popular image format used on web.
Here, we would like to show you how to convert PDF file into (PNG) images for your .NET applications or ASP.NET web sites. Before getting started, please make sure your development environment meets the following requirements.
- Windows XP, Windows 7, Windows 8 in x86 or x64 platform
- Windows Server 2003/2008/2012 in x86 or x64 platform
- .NET Framework 2.0, 3.0, 3.5, 4.0 and 4.5
- Microsoft Visual Studio 2005 and above versions
- .NET WinForms project, Console application and ASP.NET web programming
PDF File Loading
You may easily load a PDF document to read into your .NET program by two means.
- Load and read a local PDF file.
- Load and read PDF using stream. Both memory stream and file stream are supported.
public bool LoadPDF(string fileName);
public bool LoadPDF(Stream stream);
If your PDF file loading is completed with no error, it will return true. And false is for wrong loading.
PDF Page Counting
pqScan .NET PDF to Image Component allows you to count and get the amount of PDF document pages in .NET project. Please use the code below to perform this function.
public int PageCount;
DPI (Dots per Inch) Setting
It's quite easy to change the rendered image definition via setting DPI property. Our .NET PDF to Image Conversion Library will render the output image according to user-defined DPI property.
public double DPI;
Obtain Page Size Detail
The original size of PDF document page can be obtained by using the codes below.
public int GetPageHeight(int pageIndex);
public int GetPageWidth(int pageIndex);
Control PDF to PNG Conversion
pqScan .NET PDF to Image SDK allows you to control the way of PDF to PNG conversion. For instance, you may choose to convert a certain page of PDF to PNG only. Of course, a range of PDF pages or the whole file can also be changed to PNG image files.
public Bitmap ToImage(int pageIndex);
Moreover, you can control and reset the rendered PNG image width and height.
public Bitmap ToImage(int pageIndex, int width, int height);