Convert the PDF to TIFF using CCITT4 compression

We have code that creates a PDF, adds hyperlinks and then attempts to convert the PDF to TIFF using CCITT4 compression.

It works on Windows Server 2008. It fails on Windows Server 2003. LZW works on Windows Server 2003.

I need CCITT4 to work on Windows Server 2003.

Have you run into this problem before?

Thanks in advance,
HQ

@hquiggins

Thank you for contacting support.

We are afraid this problem may not be related with Aspose.PDF for .NET API so you may try some solutions suggested over different platforms. For instance, below link suggests some workarounds to avoid this error.

Let me clarify a bit.

Here is the code I am using:

    private static void ConvertPDF2TIF(string p_tiffile, string p_prtfile, string p_pdffile)
    {
        //Start Creating a TIF file here
        string intifFile = p_tiffile;
        string pdfFile = p_pdffile;
        string prtFile = p_prtfile;

        SI.QLib.IO oFA = new SI.QLib.IO();
        if (oFA.FileExists(intifFile))  //If there is a TIF already in the TIF folder
            oFA.FileDelete(intifFile);  //Delete it
        if (oFA.FileExists(prtFile))    //If there is a Tif already in the Print folder
            oFA.FileDelete(prtFile);    //Delete it


        //create PdfConverter object and bind input PDF file
        Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter();

        // create Resolution object with 300 as an argument
        // specify the resolution value for PdfConverter object - default is 150
        Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
        pdfConverter.Resolution = resolution;

        // bind the source PDF file
        pdfConverter.BindPdf(pdfFile);

        // start the conversion process
        pdfConverter.DoConvert();

        //create TiffSettings object, set Compression and ColorDepth
        Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();

        tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.CCITT4;

        pdfConverter.SaveAsTIFF(intifFile, tiffSettings);

        pdfConverter.Close();



        //Move files 
        System.IO.FileInfo oTifFInfo = new System.IO.FileInfo(intifFile);  //Get file info on the Tif in the Tiff folder
        oTifFInfo.CopyTo(prtFile);      //Copy Tif file to Print Folder
        oTifFInfo = null;

        //File Cleanup
        oFA.FileDelete(intifFile);      //Get rid of the Tiff file in the Tiff folder
        oFA = null;
    }

On Windows Server 2003, if I use CompressionType.LZW the SaveAsTIFF function WORKS creating an 11 meg TIFF file.

However on the same machine, when I change to CompressionType.CCITT4 the function fails with generic error occurred in GDI+.

@hquiggins

Thank you for clarifying.

Can you please try some solutions suggested over shared link, like loading the PDF file as byte array and instantiating a MemoryStream, then passing that stream object to BindPdf method, if that helps. Moreover, please also elaborate if this error is document specific or occurs with any PDF document. In case the issue persists, then please share sample PDF document so that we may investigate further to help you out.

I changed the code as you suggested. Created a memory stream and passed that to BindPdf(). The code still failed.

About your second question… The code errors on EVERY PDF. It is not PDF specific.

I edited this post to upload the PDF so you should have a sample.

new code:
private static void ConvertPDF2TIF(string p_tiffile, string p_prtfile, string p_pdffile)
{
//Start Creating a TIF file here
string intifFile = p_tiffile;
string pdfFile = p_pdffile;
string prtFile = p_prtfile;

        SI.QLib.IO oFA = new SI.QLib.IO();
        if (oFA.FileExists(intifFile))  //If there is a TIF already in the TIF folder
            oFA.FileDelete(intifFile);  //Delete it
        if (oFA.FileExists(prtFile))    //If there is a Tif already in the Print folder
            oFA.FileDelete(prtFile);    //Delete it



        using (System.IO.MemoryStream memory = new System.IO.MemoryStream())
        {
            using (System.IO.FileStream fs = new System.IO.FileStream(pdfFile, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite))
            {
                fs.CopyTo(memory);
                //byte[] bytes = memory.ToArray();


                //create PdfConverter object and bind input PDF file
                Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter();

                // create Resolution object with 300 as an argument
                // specify the resolution value for PdfConverter object - default is 150
                Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);
                pdfConverter.Resolution = resolution;

                // bind the source PDF file
                pdfConverter.BindPdf(memory);

                // start the conversion process
                pdfConverter.DoConvert();

                //create TiffSettings object, set Compression and ColorDepth
                Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();

                //tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.CCITT4;
                tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.LZW;

                pdfConverter.SaveAsTIFF(intifFile, tiffSettings);

                pdfConverter.Close();
            }
        }




        //Move files 
        System.IO.FileInfo oTifFInfo = new System.IO.FileInfo(intifFile);  //Get file info on the Tif in the Tiff folder
        oTifFInfo.CopyTo(prtFile);      //Copy Tif file to Print Folder
        oTifFInfo = null;

        //File Cleanup
        oFA.FileDelete(intifFile);      //Get rid of the Tiff file in the Tiff folder
        oFA = null;
    }

cnf00000_01N49G9_436_597464958654851.pdf (1.6 MB)

@hquiggins

Thank you for elaborating it further.

We have logged a ticket with ID PDFNET-46012 in our issue management system for detailed investigations. We will let you know as soon as some significant updates will be available. Please be patient and spare us some time.