Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 1038

Not able to convert pdf to tiff

$
0
0
Not able to convert pdf to tiff .Attaching the pdf file which cause the problem.
We are using Aspose.pdf v9.1.0

Using the below code:
 public static System.Drawing.Image[] ConvertPDFtoMultiPageTiff(string OutputFolder, string FullInputFileName)
        {
            System.Drawing.Image[] sourceImages = null;

            try
            {
               
                Document pdfDocument = new Document(FullInputFileName);
                //create Resolution object
                Resolution resolution = new Resolution(300);
                //create TiffSettings object
                TiffSettings tiffSettings = new TiffSettings();

                tiffSettings.Compression = CompressionType.CCITT4;
                tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format8bpp;

              
                if (tiffSettings.Shape == ShapeType.Landscape)
                    tiffSettings.Shape = ShapeType.Portait;
                tiffSettings.SkipBlankPages = false;
                //tiffSettings.Brightness = .40f;

                Stream output = null;
                sourceImages = new System.Drawing.Image[pdfDocument.Pages.Count];
                //create TIFF device
                TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);


                for (int page = 1; page <= pdfDocument.Pages.Count; page++)
                {
                    Aspose.Pdf.ColorType pageColorType = pdfDocument.Pages[page].ColorType;
                    if (pageColorType == ColorType.Rgb)
                    {
                        tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
                    }

                    else
                    {
                        tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp;
                    }

                    output = new MemoryStream();
                    //tiffDevice.Process(pdfDocument, page, page, Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".",page.ToString().PadLeft(3, '0'))));

                    tiffDevice.Process(pdfDocument,page,page, output);


                    sourceImages[page - 1] = System.Drawing.Image.FromStream(output);

                    sourceImages[page-1].Save(Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".", page.ToString().PadLeft(3, '0'))));

                    output = null;
                   
                }


              

            }
            catch (Exception ex)
            {
                sourceImages = null;
                throw new Exception(String.Format("Error in splitTiffPages: {0}", ex.Message));
            }


            return sourceImages;
        }

Viewing all articles
Browse latest Browse all 1038

Trending Articles