This project has moved and is read-only. For the latest updates, please go here.

Read PDF - 4 times the number of pages in collection

Sep 17, 2015 at 6:22 PM
Hello everyone,

My aim is to convert PDF documents to Jpeg files. Simple for now.

My Csharp application reads the PDF file and saves a jpg version using Magick.NET
(I use version 7 of Magick.NET running .NET 4.5)

I've found out recently that for some PDF files that customers drop into my app that I end up with 4 times the amount of pages that the PDF file has.

All i'm doing is pretty basic and just comes down to this:

using (var imageCollection = new MagickImageCollection())
{
imageCollection.Read(<PathToThePDFFile>, new MagickReadSettings { Density = new PointD(<myDPISettings>, <myDPISettings>)});

// further processing code down there ...
}

It is behaving fine for some PDFs, but for some that have background images or more slightly evolved layout in the pages, i end up with the collection having items being 4 times the number of PDF pages.

So if i look at one PDF page, the 4 corresponding images have differences in them. So for instance the first one only has the original text, then the second has the text plus part of the background image and so on.

I have tried flattening the images, but again it doesn't really work as I want to end up with the same amount of Jpegs than PDF pages.
I've also played with various DPI settings, but with no luck

I'm basically wondering if Magick.NET and ImageMagick can convert more complex PDF files.
This is really important for my application as a lot of users are now feeding these types of PDF into my system.

Have you ever run into this problem before?
If so any advice? or another third party solution that could help (free or not is not problem)

Thank you
Sep 17, 2015 at 8:32 PM
I have never heard about this issue. Is it possible to share one of the PDF files that has this issue? Feel free to contact me through CodePlex if you don't want to publicly share your file. And which version of GhostScript are you using? This is most likely a bug in GhostScript.
Sep 17, 2015 at 10:59 PM
Just sent it to you via PM.

I have tried running a image magick command line convert on the problematic files, but it converted the right number of them though.
That's odd
Sep 17, 2015 at 11:08 PM
Forgot to mention the following running versions:

Ghostscript 9.16
ImageMagick 6.9.1
Magick.NET 7
Sep 18, 2015 at 11:53 AM
Ok so i resolved the issue by referencing the AnyCpu version of Magick.NET

It seems that the 64 version has some issues with Windows Server 2012
Sep 18, 2015 at 12:18 PM
Edited Sep 18, 2015 at 12:18 PM
Did you also install a 64-bit version of Ghostscript? It might be picking another version of Ghostscript when you run it inside a 64-bit application pool.