tags:

views:

228

answers:

4

Hello guys,

Can anyone point me to a .net library that is capable of exporting a PDF document to a set of images, where each image represents a page from the original PDF file.

Any suggestions would be highly appreciated!

Best Regards, K

A: 

Look at http://sourceforge.net/search/?type%5Fof%5Fsearch=soft&words=PDF+CONVERTER

In particular look at

http://sourceforge.net/projects/conversio/ http://sourceforge.net/projects/qpdf2swf/ http://sourceforge.net/projects/pdfsharp/ PDFsharp is a .NET library for creating and modifying Adobe PDF documents programmatically from any .NET language like C# or VB.NET. PDFsharp defines classes for the objects found in PDF files, so you never have to deal with IDs or references directly. http://www.codeproject.com/showcase/pdfrasterizer.asp

Pandiya Chendur
But can any of these render a PDF page to an image file?
Jørn Schou-Rode
Oh, I now see there is a link to an article about PDFRasterizer in the end of your answer. The first four links seems kind of irrelevant to the question, though.
Jørn Schou-Rode
+1  A: 

Here is an article that explains about this, however note that it uses the GhostScript API: http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx

Konamiman
+1 for the open source solution, but IMHO this solution is really messy, as it relies on have both input and output files written to disk. Also P/Invoke requires privileges that aren't always unavailable, eg if used in a web application.
Jørn Schou-Rode
@Jørn Schou-Rode: +1 for giving me an excuse to tell someone to just buy a third-party tool rather than have me keep fighting with open-source tools like ImageMagicNet.
Phil
A: 

Have a look at this

100% .NET component for rendering PDF documents.

astander
+2  A: 

After evaluation several free libraries (some of them mentioned in the other answers) and several demo versions of commercial libraries, we ended up using TallComponents PDFRasterizer.NET.

The rendered images look exactly like the PDFs displayed in a reader, and the API integrates well with System.Drawing, which is nice because it allows you to do any kind of transformation to the ouput before serializing the image file to disk/network:

public ThumbnailGenerator(FileInfo pdfFile) 
{ 
    using (var pdfStream = pdfFile.OpenRead()) 
    { 
        var doc = new Document(pdfStream); 
        var page = doc.Pages[0]; 

        using (var image = new Bitmap((int)page.Width, (int)page.Height))
        using (var gfx = Graphics.FromImage(image))
        {
            page.Draw(gfx); 
            AddSuperFancyReflectionEffect(gfx);
            image.Save(fileName, ImageFormat.Png);
        }
    } 
}

Live sample: all cover images on Bookboon.com is generated using code similar to what is shown above.

Jørn Schou-Rode
Jørn: I believe using (var gfx Graphics.FromImage(baseImage)) should actually be using (var gfx Graphics.FromImage(image)) and using (var gfx Graphics.FromImage(baseImage)) should actually be using (var gfx = Graphics.FromImage(baseImage))
scott
@scott: the errors are now corrected, thanks! :)
Jørn Schou-Rode