XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to HTML5 Viewer & Editor PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Convert PDF to Tiff
  |  
Home ›› XDoc.PDF ›› C# PDF: Convert PDF to Tiff

How to convert, turn Adobe multipage pdf to Tiff document using XDoc.PDF for .NET in C# asp.net, Ajax, WinForms, WPF, Azure


Online C# Tutorial for Converting PDF File to high quality Tiff Image File with .NET XDoc.PDF Control in C#.NET Class. Free Online Trial Download.




Best C#.NET PDF converter SDK for converting PDF to Tiff in Visual Studio .NET project


Powerful .NET converter control to batch convert PDF documents to tiff format in Visual C# .NET program


Free library are given for converting PDF to Tiff in both C# .NET WinForms and ASP.NET application


Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint


Tiff files are exported with high resolution and no loss in quality in .NET framework


Both single page and multipages tiff image files can be created from PDF


Supports tiff compression selection


Supports for changing image size


Also supports convert PDF files to jpg, jpeg images


C# class source codes and online demos are provided for .NET


RasterEdge C#.NET PDF to TIFF converting library control (XDoc.PDF) is a multifunctional PDF document converting tool, which can perform high-fidelity PDF to TIFF conversion in an easy way. Using this .NET PDF to TIFF conversion control, C# developers can render and convert PDF document to TIFF image file with no loss in original file quality. Both single page and multi-page Tiff image files are acceptable.




Use C#.NET DLLs and Demo Code to Convert PDF to Tiff in C#.NET Program

Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.


C# programming sample for PDF to Tiff image converting.



        #region pdf to tiff (file to file)
        internal static void pdfToTiff()
        {
            String inputPath = @"C:\demo.pdf";
            String outputPath = @"C:\output.tif";
            PDFDocument doc = new PDFDocument(inputPath);
            doc.ConvertToDocument(DocumentType.TIFF, outputPath);
        }
        #endregion

        #region pdf to tiff (stream to stream)
        internal static void pdfStreamToTiff()
        {
            String inputPath = @"";
            byte[] arr = File.ReadAllBytes(inputPath);
            Stream inputStream = new MemoryStream(arr);
            PDFDocument doc = new PDFDocument(inputStream);
            Stream outputStream = new MemoryStream();
            doc.ConvertToDocument(DocumentType.TIFF, outputStream);
        }
        #endregion




C# convert, turn two or multiple pdf files to tiff (batch conversion)





        #region pdf to tiff (batch files and single tread)
        internal static void pdfFilesToTiff()
        {
            String inputDirectory = @"C:\input\";
            String outputDirectory = @"C:\output\";
            String[] files = Directory.GetFiles(inputDirectory, "*.pdf");
            foreach (String filePath in files)
            {
                int startIdx = filePath.LastIndexOf("\\");
                int endIdx = filePath.LastIndexOf(".");
                String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
                PDFDocument doc = new PDFDocument(filePath);
                doc.ConvertToDocument(DocumentType.TIFF, outputDirectory + docName + ".tif");
            }
        }
        #endregion

        #region pdf to tiff (batch files and multiple treads)
        internal static void pdffiles22Tiff()
        {
            String inputDirectory = @"C:\input\";
            String outputDirectory = @"C:\output\";
            String[] files = Directory.GetFiles(inputDirectory, "*.pdf");
            List<ConversionArgs> args = new List<ConversionArgs>();
            foreach (String filePath in files)
            {
                int startIdx = filePath.LastIndexOf("\\");
                int endIdx = filePath.LastIndexOf(".");
                String docName = filePath.Substring(startIdx + 1, endIdx - startIdx - 1);
                ConversionArgs arg = new ConversionArgs(filePath, outputDirectory + docName + ".tif");
                args.Add(arg);
            }

            List<Thread> threads = new List<Thread>();
            foreach (ConversionArgs arg in args)
            {
                Thread thread = new Thread(pdfToTiffThread);
                thread.Start(arg);
            }
            foreach (Thread thread in threads)
            {
                thread.Join();
            }
        }

        private static void pdfToTiffThread(object args)
        {
            ConversionArgs toPdfArgs = (ConversionArgs)args;
            PDFDocument srcDoc = new PDFDocument(toPdfArgs.SrcPath);
            if (srcDoc != null)
            {
                srcDoc.ConvertToDocument(DocumentType.TIFF, toPdfArgs.DstPath);
                srcDoc.Dispose();
            }
        }
        #endregion




C# combine multiple pdf files, and convert to tiff





        #region combine and convert pdf to single tiff file
        internal static void combineAndConvertPdfToTiff()
        {
            String[] files = new String[] { @"C:\demo1.pdf", @"C:\demo2.pdf", @"C:\demo3.pdf" };
            String outputFilePath = @"C:\output.tif";
            List<MemoryStream> streams = new List<MemoryStream>();
            foreach (String file in files)
            {
                MemoryStream outputStream = new MemoryStream();
                PDFDocument doc = new PDFDocument(file);
                doc.ConvertToDocument(DocumentType.TIFF, outputStream);
                streams.Add(outputStream);
            }
            TIFFDocument.CombineDocument(streams.ToArray(), outputFilePath);
        }
        #endregion




C# insert pdf pages into tiff file and create a new tiff file





        #region insert pdf to tiff
        internal static void insertPdfToTiff()
        {
            String filePath = @"C:\demo.pdf";
            PDFDocument doc = new PDFDocument(filePath);
            MemoryStream stream = new MemoryStream();
            doc.ConvertToDocument(DocumentType.TIFF, stream);
            TIFFDocument tif = new TIFFDocument(stream);
            int pageCount = tif.GetPageCount();
            List<BasePage> pages = new List<BasePage>();
            for (int i = 0; i < pageCount; i++)
            {
                pages.Add(doc.GetPage(i));
            }
            String outputTif = @"C:\output.tif";
            TIFFDocument desDoc = new TIFFDocument(outputTif);
            int insertLocation = 2;
            desDoc.InsertPages(pages.ToArray(), insertLocation);
            desDoc.Save(@"C:\desDocumcnet.tif");
        }
        #endregion




C# convert pdf to tiff with specified dpi resolutions





        #region convert pdf file to Tiff with specified resolution
        internal static void convertPdfFileToTiffWithSpecified()
        {
            String inputFilePath = @"C:\demo.pdf";
            String outputFilePath = @"C:\demo.tif";
            PDFDocument doc = new PDFDocument(inputFilePath);
            doc.ConvertToDocument(DocumentType.TIFF, 300, outputFilePath);
        }
        #endregion




C# convert pdf to tiff with specified colorspace (color, grayscale, monochrome or black & white) settings





        #region convert pdf file to Tiff with specified colorspace settings
        internal static void convertPdfFileToTiffWithSpecifiedSettings()
        {
            String inputFilePath = @"C:\demo.pdf";
            String outputFilePath = @"C:\demo.tif";
            PDFDocument doc = new PDFDocument(inputFilePath);

            //set image output settings
            ImageOutputOption option = new ImageOutputOption();
            option.Color = ColorType.Monochrome;
            //...

            doc.ConvertToDocument(DocumentType.TIFF, outputFilePath, option);
        }
        #endregion




.NET Class Namespace Required



Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


  RasterEdge.XDoc.TIFF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;





public override void ConvertToDocument(DocumentType targetType, String filePath)

Description:
     Convert to DOCX/TIFF and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, Stream stream)

Description:
     Convert to DOCX/TIFF and save it into stream.

Parameters:



public override void ConvertToDocument(DocumentType targetType, float zoomValue, String filePath)

Description:
     Convert to DOCX/TIFF with specified zoom value and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, float zoomValue, Stream desStream)

Description:
     Convert to DOCX/TIFF with specified zoom value and save it into stream.

Parameters:



public override void ConvertToDocument(DocumentType targetType, int resolution, String filePath)

Description:
     Convert to DOCX/TIFF with specified resolution and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, int resolution, Stream desStream)

Description:
     Convert to DOCX/TIFF with specified resolution and save it into stream.

Parameters:



public override void ConvertToDocument(DocumentType targetType, ImageCompress compression, String filePath)

Description:
     Convert to DOCX/TIFF with specified compression method and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, ImageCompress compression, Stream desStream)

Description:
     Convert to DOCX/TIFF with specified resolution and save it into stream.

Parameters:



public override void ConvertToDocument(DocumentType targetType, string filePath, ImageOutputOption options)

Description:
     Convert to DOCX/TIFF with specified settings through options and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, Stream desStream, ImageOutputOption options)

Description:
     Convert to DOCX/TIFF with specified resolution and save it into stream.

Parameters: