Free Support Forum -

PDF to Single Page TIFF

I need to convert all pages of a PDF to single image(s) TIFF with compression 4. This code works for JPEG but says that TIFF is not supported, any ideas?

//create return object
List<byte[]> images = new List<byte[]>();
//Create Converter
Aspose.Pdf.Facades.PdfConverter converter = new Aspose.Pdf.Facades.PdfConverter();
            <span style="color:green;">//Load Byte Array to Stream</span>
            <span style="color:blue;">using</span> (<span style="color:#2b91af;">MemoryStream</span> inputStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>(InputFile))
                <span style="color:green;">//Load PDF</span>
                converter.StartPage = 1;
                converter.EndPage = converter.PageCount;
                <span style="color:green;">//each page conversion</span>
                <span style="color:blue;">while</span> (converter.HasNextImage())
                    <span style="color:green;">//Save</span>
                    <span style="color:blue;">using</span> (<span style="color:#2b91af;">MemoryStream</span> outputStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>())
                        converter.GetNextImage(outputStream, <span style="color:#2b91af;">ImageFormat</span>.Jpeg, 200, 200, 100);
            <span style="color:green;">//return</span>
            <span style="color:blue;">return</span> images;
        <span style="color:blue;">finally</span>
            <span style="color:green;">//Close Converter</span>

Hi Luis,

Thanks for using our products. From compression 4, do you mean CCITT4 compression ? If so is the case, then I would suggest you to please try using the code snippet shared over following link and set the value of TiffSettings.Compression to CompressionType.CCITT4. In case you still face any issue, please share the source PDF file so that we can test the scenario at our end. We apologize for your inconvenience.

Convert all PDF pages to single TIFF Image

Hi Luis,

Thanks for using our products.
You may check the following documentation links for details and code snippets as per your requirement.
Convert all PDF pages to single TIFF Image
Please do let us know if you need any further assistance.

Thanks & Regards,

Thanks is working now. Just in case someone need the code:

using (MemoryStream inputStream = new MemoryStream(InputFile))
//Load PDF
Document pdfDocument = new Document(inputStream);
//Set TIFF Options
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.CCITT4;
tiffSettings.Depth = ColorDepth.Format1bpp;
tiffSettings.SkipBlankPages = false;
//create TIFF device
Resolution resolution = new Resolution(200);
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
//convert each page
for (int i = 0; i < pdfDocument.Pages.Count; i++)
using (MemoryStream outputStream = new MemoryStream())
tiffDevice.Process(pdfDocument, i+1, i+1, outputStream);