How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# TIFF to PDF Library
How to convert multipage Tiff image files to PDF using C# code in ASP.NET, Winforms, Azure, Sharepoint


Full sample source code for converting Tiff to PDF document in C# Programming Language. Free Online Trial Download.





In this tutorial, you learn how to convert Tiff (.tif) to PDF file using C# Tiff to PDF Conversion library in .NET Windows, ASP.NET applications.

  • Convert multipage Tiff to Scanned PDF file
  • Convert Tiff to editable PDF document using OCR
  • Convert multiple Tiff image files to PDFs
  • Combine Tiff files and convert to a PDF file
  • Insert Tiff file into PDF pages

How to convert Tiff to PDF file using C#

  1. Download XDoc.PDF Tiff conversion C# library
  2. Install C# library to convert Tiff TO Adobe PDF file
  3. Step by Step Tutorial












In addition to PDF to Tiff conversion, our .NET PDF document imaging SDK also supports conversion from Tiff image to PDF document in C# class. Similarly, Tiff image with single page or multiple pages is supported.





C#: Multi-page tiff to Adobe PDF document Conversion in Visual C# .NET Class


Please copy the following C#.NET demo code to have a quick evaluation of our XDoc.PDF file conversion functionality.



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

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






Convert tiff file to editable PDF document using C#


If you need get editable PDF document from a Tiff file, you need OCR SDK to extract text from tiff files.



using RasterEdge.XDoc.Converter;

String inputFilePath = Path.Combine(inputFolder, "1.tif");
String outputFilePath = Path.Combine(inputFolder, "output.pdf");

DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF);
// The folder that contains '.traineddata' files.
ops.OcrSourcePath = @"C:\Source";
//  Convert to editable PDF file.
ops.IsSearchable = true;

DocumentConverter.ToDocument(inputFilePath, outputFilePath, ops);






C# convert two or multiple Tiff files to PDF (batch, bulk conversion)


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

        #region tiff to pdf (batch files and multiple treads)
        internal static void tifffiles22pdf()
        {
            String inputDirectory = @"C:\input\";
            String outputDirectory = @"C:\output\";
            String[] files = Directory.GetFiles(inputDirectory, "*.tif");
            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 + ".pdf");
                args.Add(arg);
            }

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

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




C# combine multiple Tiff files into PDF


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




C# insert Tiff file into pdf document, and create a new PDF file


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