Hello folks.,
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 3rd party dll?
any pointers ?
thank you
Hello folks.,
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 3rd party dll?
any pointers ?
thank you
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
Converting PDF to images is not something that you can dow ith .NET out of the box. It requires processing and rendering of the document which is not trivial. I don't think there is any way to do this without third party components.
For a commercial solution, try PDFRasterizer.NET from TallComponents which is specifically designed for this task.
Full disclosure: I have worked for TallComponents.
I used PDF4NET from O2 a few times in the past and was pretty satisfied http://www.o2sol.com/pdf4net/overview.htm
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