The following free C# sample code shows how to convert PDF to BMP image in Visual Studio .NET project. You may also get more details for .NET PDF to BMP converting properties and APIs here.
using System; using System.Drawing; using System.Drawing.Imaging; using PQScan.PDFToImage; namespace PDF2BMP { class Program { static void Main(string[] args) { // Create an instance of PQScan.PDFToImage.PDFDocument object. PDFDocument pdfDoc = new PDFDocument(); // Load a PDF document. pdfDoc.LoadPDF("sample.pdf"); // Get the total page count. int count = pdfDoc.PageCount; for (int i = 0; i < count; i++) { // Rasterize PDF page to image. Bitmap bitmap = pdfDoc.ToImage(i); // Save image to bmp file type. bitmap.Save("output" + i + ".bmp", ImageFormat.Bmp); } } } }
In addition, here's a C# coding sample for how to load a PDF from stream and transform it to the right size BMP image file. That is to say, you are empowered to customize the size of output BMP image according to your specific PDF document converting requirement.
using System; using System.IO; using System.Drawing; using System.Drawing.Imaging; using PQScan.PDFToImage; namespace PDFToBMP { class Program { static void Main(string[] args) { // Make a new instance of PQScan.PDFToImage.PDFDocument object. PDFDocument pdf = new PDFDocument(); // Create a file stream with PDF information. FileStream stream = new FileStream("sample.pdf", FileMode.Open); // Load PDF document from file stream. pdf.LoadPDF(stream); // Set output bmp image width. int width = pdf.GetPageWidth(0) / 2; // Set output bmp image height. int height = pdf.GetPageHeight(0) / 2; // Convert the first page of PDF to image with the desired size. Bitmap bmp = pdf.ToImage(0, width, height); // Save image to bmp image file format. bmp.Save("result.bmp", ImageFormat.Bmp); } } }
If you want to resize BMP image and change its quality through DPI, you may refer to this online C# tutorial: How to customize (BMP) image converted from PDF page using C#.