Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Getting error/pdf.c/ReadPDFImage/788 From Example Code

$
0
0
The new exception says
An unhandled exception of type 'ImageMagick.MagickCoderErrorException' occurred in Magick.NET-Q8.Wrapper-x86.dll

Additional information: PDF PoC Revisited.vshost.exe: WriteBlob Failed `c:\users\xxxx\documents\visual studio 2013\Projects\PDF PoC Revisited\PDF PoC Revisited\bin\Debug\Image Extract\Terms of Service.Page1.150DPI.png' @ error/png.c/MagickPNGErrorHandler/1650
All my code from main:
            var imageOutputDpi = 150;

            var magickSettings = new MagickReadSettings();
            magickSettings.Density = new PointD(imageOutputDpi, imageOutputDpi);
            magickSettings.Format = MagickFormat.Png;
            magickSettings.ColorSpace = ColorSpace.GRAY;

            using(var imageCollection = new MagickImageCollection())
            {
                var assemblyLocation = Assembly.GetExecutingAssembly().Location;
                var assemblyDirectory = assemblyLocation.Remove(assemblyLocation.LastIndexOf('\\') + 1);
                var pdfFileName = "Terms of Service Agreement 2014";
                var pdfLocation = string.Format("{0}{1}{2}", assemblyDirectory, pdfFileName, ".pdf"); //[Assembly Directory]\Terms of Service Agreement 2014.pdf

                if (File.Exists(pdfLocation)) imageCollection.Read(pdfLocation, magickSettings);

                var outputFolderName = "Image Extract";
                var pdfOutputDirectory = string.Format("{0}{1}\\", assemblyDirectory, outputFolderName); //[Assembly Directory]\Image Extract\
                var pdfOutputPostfixFormat = ".Page{0}.{1}DPI";

                var pageNumber = 1;
                foreach (var image in imageCollection)
                {
                    var pdfOutputPostfix = string.Format(pdfOutputPostfixFormat, pageNumber, imageOutputDpi); //.Page1.150DPI
                    var imageOutputLocation = string.Format("{0}{1}{2}{3}", pdfOutputDirectory, "Terms of Service", pdfOutputPostfix, ".png"); //[Assembly Directory]\Image Extract\Terms of Service.Page1.150DPI.png
                    image.Write(imageOutputLocation);

                    pageNumber++;
                }
            }

            Console.WriteLine("done");
            Console.Read();

Viewing all articles
Browse latest Browse all 3693

Trending Articles