Convert PDF to Image

I'm using the magick to convert PDF to Images.

I need to convert the PDF to multiples images. One image by page of PDF.

I have tryed to use this code:


using ImageMagick;
 void Teste()
    {


        MagickReadSettings settings = new MagickReadSettings();
        // Settings the density to 300 dpi will create an image with a better quality
        settings.Density = new PointD(300, 300);

        using (MagickImageCollection images = new MagickImageCollection())
        {
            // Add all the pages of the pdf file to the collection
            images.Read("Snakeware.pdf", settings);

            int page = 1;
            foreach (MagickImage image in images)
            {
                // Write page to file that contains the page number
                image.Write("Snakeware.Page" + page + ".png");
                // Writing to a specific format works the same as for a single image
                image.Format = MagickFormat.Ptif;
                image.Write("Snakeware.Page" + page + ".tif");
                page++;
            }
        }
    }

I have the erro : The type or namespace name "MagickImageCollection" could not be found (are you missing a using directive or an assembly reference?).

I have checked the references and everytinhg is oK.

I'm using the directive using ImageMagick;

What is wrong?

If anyone has another free option, let me know.
Anderson MenesesDeveloppmentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Naitik GamitSoftware DeveloperCommented:
Add the assembly to the web.config :

<system.web>
<compilation>
<assemblies>
 <addassembly="Magick.NET-x64"/>
</assemblies>
</compilation>
</system.web>
Joe Winograd, Fellow&MVEDeveloperCommented:
Hi berechit,

I don't know if this will interest you, but here's a different approach. You could make a call from your code to an ImageMagick or GraphicsMagick command line with the +adjoin parameter. Here are three EE articles that discuss GraphicsMagick and how to call it when dealing with PDF and JPG files:

Reduce the file size of many JPG files in many folders via an automated, mass, batch compression method

Create a PDF file with Contact Sheets (montage of thumbnails) for all JPG files in a folder and each of its subfolders using an automated, batch method

Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF

For your particular requirement, the command line call is this:

gm.exe convert input.pdf +adjoin output%02d.jpg

That's it — just one line of code. If you have, for example, a three-page PDF, that command line call will create:

output00.jpg
output01.jpg
output02.jpg

You may control the output file names via a printf style formatting specification for the numeric part of the file name and any string that you want for the leading part of the file name.

I use GraphicsMagick rather than ImageMagick, but if you prefer ImageMagick, I know that it also supports the +adjoin parameter. Regards, Joe

Update: I decided this is worthy of its own article:
Convert a multi-page PDF file into multiple image files

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.