Converting PDF to images using ImageMagick.NET - how to set the DPI

Posted by Avi Pinto on Stack Overflow See other posts from Stack Overflow or by Avi Pinto
Published on 2010-05-26T20:33:02Z Indexed on 2010/05/29 5:32 UTC
Read the original article Hit count: 553

Filed under:
|
|
|

Hi, I'm trying to convert pdf files to images. ImageMagick is a great tool, and using the command line tool gets me desired result.

but i need to do this in my code, So added a reference to http://imagemagick.codeplex.com/ And the following code sample renders each page of the pdf as an image:

MagickNet.InitializeMagick();
using (ImageList im = new ImageList())
{
    im.ReadImages(@"E:\Test\" + fileName + ".pdf");
    int count = 0;
    foreach (Image image in im)
    {
        image.Quality = 100;
        image.CompressType = mageMagickNET.CompressionType.LosslessJPEGCompression;
        image.Write(@"E:\Test\" + fileName + "-" + count.ToString() + ".jpg");
        ++count;
    }
}

The problem: IT LOOKS LIKE CRAP the rendered image is hardly readable. the problem i realized is it uses the default 72 DPI of ImageMagick. and i can't find a way to set it(96dpi or 120dpi gives good results) via the .Net wrapper.

Am I missing something , or there is really no way to set it via this wrapper?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about pdf