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

Saving Tiffs to PDF receiving "No space for output buffer" error

Oct 28, 2016 at 4:06 AM

I am using Magick.NET v7.0.3.500 with C# in VS 2015, the Magick.NET-Q8-AnyCpu version. It is working great for me for the most part.

I am using the following code to combine a directory of Single page Bi-tonal tiff images into a multi-page PDF file:
   using (ImageMagick.MagickImageCollection collection = new ImageMagick.MagickImageCollection())
                foreach (string tiffile in tiffiles)
                    tiffileForErr = tiffile;
                    collection.Add(new ImageMagick.MagickImage(tiffile));


I am occasionally receiving the error: "No space for output buffer. `TIFFWriteBufferSetup' @ error/tiff.c/TIFFErrors/565

This seems to occurs on directories that have a large number of tiff files(500 or more images). The partial PDF get's written out, and even when opening the PDF it indicates the correct page count, but when trying to view after a certain image an error occurs.

Is there any other code I can put in place in the method above to prevent, or allow for a successful creation of the PDF file?

Any help would be greatly appreciated.
Oct 29, 2016 at 7:03 AM
It appears that you are running out of memory. But the odd part of that exception is that looks like it is happening inside the tiff writer. It might be possible that the tiff coder is being used when the PDF is being written but I cannot find that with a quick look at the code. Maybe you could do some experimenting with the Compression property of the MagickImage. I wonder if setting it to something like RLE will resolve your issue.
Oct 31, 2016 at 8:18 PM
I tried changing compression to RLE and the same results happened. I also tried using Group 4 since that is the format of all my images, and same thing occured as well.
Nov 1, 2016 at 9:38 PM
Is it possible to reproduce your issue with a single image and a for loop where you add the same image 500-1000 times? Would help me out a lot if you would share an image and a small code sample that I can use to reproduce it.