Convert PDF file to images using C#

10,040

Solution 1

You can also use a c# code that is easly downloadable from Code Project that use Ghostscript

http://www.codeproject.com/KB/cs/GhostScriptUseWithCSharp.aspx

Solution 2

Not a huge job, as it has already been done :)

you'll need ghostscript installed (mainly gsdll32.dll), and the c# wrapper from http://redmanscave.blogspot.com/

It's one .cs file. For some reason you'll have to email him for the file, it is not posted.

To convert you'll just a few lines, for example:

    string cl2 = @"-dSAFER -dNoVerifyXref -dQUIET -dNOPROMPT"
      + " -dBATCH -dNOPAUSE -sDEVICE=jpeg -r72 -dFirstPage=1 "
      +  "-dLastPage=1 -dUseCropBox -sOutputFile=" + SourceFile 
      + " " + TargetFile;

    try
    {
        Made4Print.GhostScript gs = 
            new Made4Print.GhostScript(@"[path-to-gs-installation]");
        gs.CallGSDll(cl2.Split(' '));
    }
    catch
    {
        //exception handler
    }    

this saves 1st page as jpeg @ 72 dpi

Solution 3

I used PDF4NET from O2 a few times in the past and was pretty satisfied http://www.o2sol.com/pdf4net/overview.htm

Share:
10,040
As k
Author by

As k

very much interested in learning new things.

Updated on June 18, 2022

Comments

  • As k
    As k almost 2 years

    Using C#, I need to convert each page of a PDF file into separate images and display the images.

    Is it possible to do this without using a 3rd party DLL?