C# PDF to Tiff Converter Library
How to convert PDF file to multipage tiff image programmatically using C# in ASP.NET, Windows. Free open source demo code.
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.
In this tutorial, you learn how to convert PDF to Tiff file using C# PDF to Tiff Converter library in .NET Windows, ASP.NET applications.
- PDF file to multiplage Tiff image conversion
- Image color and compression supported
- Insert PDF pages into tiff file
- Create high resolution (dpi) tiff file from PDF
- Create tiff with colorspace from PDF
How to convert PDF file to multipage TIFF image programmatically using C#
- 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.
Quick to convert PDF file to multipage TIFF image using C#
Converting PDF to TIFF image using XDoc.PDF for .NET is straightforward. Use the PDFDocument class to convert the document to multiplage TIFF image directly.
Below are the steps and sample C# code.
- Create a new PDFDocument object and load an existing PDF file to it.
- Use PDFDocument.ConvertToDocument() method to convert PDF to TIFF image
String inputFilePath = @"W:\Projects\Test-Files\file1.pdf";
String outputFilePath = @"W:\Projects\Test-Output\RasterEdge.com\pdf-convert-pdf-to-tiff-quick.tif";
// Open file
PDFDocument doc = new PDFDocument(inputFilePath);
// Convert whole document to TIFF file
doc.ConvertToDocument(DocumentType.TIFF, outputFilePath);
PDF to TIIF Convert Image Options
Using XDoc.PDF for .NET, you can easily convert multi-pages PDF file into tiff.
The following Tiff document settings supported in class "ImageOutputOption":
- Color: Output image is Monochrome, Gray, Color.
- Compression: defines the compression scheme used on the image data in the output TIFF file. Valid values:
Uncompressed: No compression used.
PackBits: Using a simple byte-oriented run-length scheme.
CCITT1D: Using CCITT Group 3 1-Dimensional Modified Huffman run-length encoding.
Group3Fax: Using CCITT T.4 bi-level encoding.
Group4Fax: Using CCITT T.6 bi-level encoding.
LZW: Using Lempel-Ziv & Welch (LZW) algorithm.
JPEG: Using JPEG baseline based on the Discrete Cosine Transform (DCT).
- Resolution: Set image resolution value in the TIFF image file.
- Zoom: Set PDF page zoom value to use more pixels to render the page.
Below are the steps and C# sample source code to convert Adobe PDF file to multipage TIFF image programmatically using C#.
- Set converted TIFF image options, including Image Color, Image Compression, Image Resolution and PDF page zoom value.
- Create a new PDFDocument object from a PDF file
- Call method PDFDocument.ConvertToDocument() to convert PDF to TIFF image file with options applied.
String inputFilePath = @"W:\Projects\Test-Files\file1.pdf";
String outputFilePath = @"W:\Projects\Test-Output\RasterEdge.com\pdf-convert-pdf-to-tiff.tif";
ImageOutputOption options = new ImageOutputOption();
// Output image is color.
options.Color = ColorType.Color;
// Use LZW compression in TIFF file.
options.Compression = ImageCompress.LZW;
// Set resolution to 300 dpi for each page.
options.Resolution = 300;
// Set zoom value to 2F. Use more pixels to render the page.
options.Zoom = 2;
// Open file
PDFDocument doc = new PDFDocument(inputFilePath);
// Convert whole document to TIFF file
doc.ConvertToDocument(DocumentType.TIFF, outputFilePath, options);
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