XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to 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
Create PDF from Tiff
  |  
Home ›› XDoc.PDF ›› C# PDF: Create PDF from Tiff

How to convert, change Tiff (.tif, . tiff) file to Adobe PDF document using C# in ASP.NET, Winforms, Azure, Sharepoint


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




Best and free C# tiff to adobe PDF converter SDK for Visual Studio .NET


.NET PDF Converter component for batch converting tiff images to PDF documents in C# class


Create PDF from Tiff in both .NET WinForms and ASP.NET application


PDF files are created from tiff with high quality using .NET PDF SDK for C#.NET


Support to combine multiple page tiffs into one PDF file


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


Selection of turning tiff into searchable PDF or scanned PDF


Online demo allows converting tiff to PDF online


C# source codes are provided to use in .NET class


Free library and components for downloading and using in .NET framework


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


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.


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




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




.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.TIFF;





public override void ConvertToDocument(DocumentType targetType, String filePath)

Description:
     Convert to PDF and save it on the disk.

Parameters:



public override void ConvertToDocument(DocumentType targetType, Stream stream)

Description:
     Convert to PDF and save it into stream.

Parameters:



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

Description:
     Convert to PDF/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 PDF with specified zoom value and save it into stream.

Parameters:



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

Description:
     Convert to PDF with specified resolution and save it on the disk.

Parameters:



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

Description:
     Convert to PDF with specified resolution and save it into stream.

Parameters:



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

Description:
     Convert to PDF with specified compression method and save it on the disk.

Parameters:



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

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

Parameters:



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

Description:
     Convert to PDF/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 PDF with specified resolution and save it into stream.

Parameters: