If you are looking for a solution to convert PDF into Jpeg images using C#, stop the searching - you're in the right place!
The PDF Focus .Net is only the one library designed for this purpose. It perfectly converts any PDF documents to Jpeg/JPG.
By creating the library, we've tried to cover all requirements from customers: only the .Net platform and nothing else, 32 and 64-bit support, Medium Trust level, converting of all types of PDF documents, works under Windows, Mac, Linux and a lot of other nuances.
Let's move forward, here we'll show you how to convert a PDF document into a set of Jpeg images using Visual Studio 2010/C#.
Type the application name and location, for example "pdf to jpeg" and "c:\samples".
(video 1:10).
Step 2: In the Solution Explorer right-click on "References" and select "Add Reference". Next add references to the "System.Drawing" and "SautinSoft.PdfFocus.dll".
(video 1:23).
Step 3: So, we've created an empty C# console application. Now type the C# code to convert our Zoo.pdf to Jpeg files with 200 dpi. (video 1:56).
Don't forget to create a folder "Pictures" inside "C:\Tutorials\", because the component does not create folders by itself.
C# code:
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
f.Serial = "XXXXX";
f.OpenPdf(@"C:\Tutorials\zoo.pdf");
if (f.PageCount > 0)
{
//Set 200 dpi and jpeg format
f.ImageOptions.Dpi = 200;
f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
//Save all pages to jpegs into the folder 'Pictures'
//P.S. The folder 'Pictures' must be existed
for (int page = 1; page <= f.PageCount; page++)
f.ToImage(@"c:\Tutorials\Pictures\"+ "page" + page + ".jpg", page);
}
If you are developing in VB.Net all steps are very similar, except you will need to select Visual Basic Console Application in the step 1.
VB.Net code:
Dim f As New SautinSoft.PdfFocus()
f.Serial = "XXXXX"
f.OpenPdf("C:\Tutorials\zoo.pdf")
If f.PageCount > 0 Then
'Set 200 dpi and jpeg format
f.ImageOptions.Dpi = 200
f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
'Save all pages to jpegs into the folder 'Pictures'
'P.S. The folder 'Pictures' must be existed
For page As Integer = 1 To f.PageCount
f.ToImage("c:\Tutorials\Pictures\" & "page" & page & ".jpg", page)
Next page
End If
Now build the application and launch it.
Well done! Our congratulations, with help of the PDF Focus .Net library we've converted all pages of PDF document to a set of Jpegs.