Convert TIFF to PDF using C#

Convert TIFF to PDF using C#

TIFF and PDF are two prevalent file formats in this ever-evolving world. TIFF documents are more accessible to edit than PDF and offer better image quality. However, there are many reasons why you need to convert TIFF to PDF. In this blog post, you will come across the steps and the code snippet to convert TIFF to PDF using C# imaging library. This image processing library offers a rich stack of methods to process & manipulate various file formats programmatically.

You will go through the following points:

C# Image processing library installation

You can download the DLL or install this enterprise-level library by running the following command in the NuGet package manager.

Install-Package Aspose.Imaging

Convert TIFF to PDF using C#

Now, you can move toward writing the code to implement the TIFF to PDF conversion programmatically in C#.

The steps are:

  1. Load the source TIFF image file by calling the Load method.
  2. Instantiate an instance of the TiffImage class.
  3. Create an object of the PdfOptions class.
  4. Initializes a new instance of the ResolutionSetting class by setting the horizontal and verticle resolutions.
  5. Invoke the Save method to save the file in PDF format.

Copy & paste the following code into your main file:

You can see the output in the image below:

tiff to pdf conversion

TIFF to PDF Converter in C# - Advanced Options

In this section, we will go into further detail about this image processing library and will see how to create an image from scratch programmatically.

You can follow the steps and the code snippet below:

  1. Create an instance of TiffOptions and set its various properties.
  2. Set the value of the BitsPerSample property to set the bits per sample.
  3. Set the value of the photometric property.
  4. Xresolution property will set the x resolution.
  5. Yresolution property will set the y resolution.
  6. Set the resolution unit by setting the value of the ResolutionUnit property.
  7. The PlanarConfiguration property will set the planar configuration.
  8. Set the Compression to AdobeDeflate.
  9. Create a new TiffImage with a specific size and TiffOptions settings.
  10. Loop over the pixels and call the SetPixel to set the color of the ActiveFrame to Red.
  11. Save the resultant image.

The following sample code is based on the steps above and can be used to convert TIFF to PDF in C#:

The output is shown in the image below:

create tiff image

Get a Free License

You can avail of a free temporary license]25 to try the API without evaluation limitations.

Summing up

This brings us to the end of this tutorial. You have gone through how to convert TIFF to PDF using C# imaging library. In addition, you also have gone through the advanced options of this image processing library. Further, you may visit the documentation of this API to know other features.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. Therefore, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

Can I change a TIFF file to PDF?

You can follow this link to get the code snippet and steps to convert TIFF to PDF programmatically.

See Also