-
Notifications
You must be signed in to change notification settings - Fork 1
Convert PDF document to Bitmap (PDF to image)
Robert edited this page Jun 17, 2013
·
7 revisions
Complete code for samples listed below can be found in Samples folder inside the download package for the product. Code provided assumes you did all the necessary preparations(added references etc.) and just gives you an idea on how potentially the task could be done.
Below is a console program that converts specific PDF file to bitmap.
using System.Diagnostics;
using System.Drawing.Imaging;
using System.IO;
using Apitron.PDF.Rasterizer;
using Apitron.PDF.Rasterizer.Configuration;
internal class Program
{
private static void Main(string[] args)
{
// open and load the file
using (FileStream fs = new FileStream(@"..\..\..\Documents\testfile.pdf", FileMode.Open))
{
// this object represents a PDF document
Document document = new Document(fs);
// process and save pages one by one
for (int i = 0; i < document.Pages.Count; i++)
{
Page currentPage = document.Pages[i];
// we use original page's width and height for image by default
currentPage.Render(new RenderingSettings()).Save(
string.Format("{0}.bmp", i), ImageFormat.Bmp);
}
// preview 1st rendered page
Process.Start("0.bmp");
}
}
}