Follow this article to convert GIF to PDF using C#. It provides details to set the IDE, a list of steps, and a sample code for developing the GIF to PDF file converter using C#. You will also learn to customize the output PDF while rendering the GIF file into it.
Steps to Change GIF to PDF using C#
- Set the IDE to use Aspose.PDF for .NET for changing a GIF file to PDF
- Import the necessary classes from the library
- Define the input GIF file and output PDF file name
- Create an object Document class and add a page to it
- Create an image object from the Aspose.PDF library
- Set the name of the input document in the File property
- Access the collection of paragraphs from the PDF and add the image to it
- Save the output PDF file with a rendered GIF in it
These steps summarize the process to turn GIF into PDF using C#. Import the Aspose.Pdf class, load a license, define the input GIF file and output PDF file names, and create the Document class object. Add a new page to the default collection of the pages in the PDF file, create an image, set the File property to the GIF file name, add an image object to the paragraphs collection in the page, and save the output PDF file.
Code to Convert GIF File to PDF using C#
This code has demonstrated the process for developing the GIF file to PDF converter using C#. You can customize the output PDF page size such that it only contains the GIF image and is exactly equal to the size of the FIG image. For this, you may set 0 value for left, right, top and bottom property in the Margin object, and set the width/height of the PDF page to the BitmapSize.Width and BitmapSize.Height property of the GIF image before saving the image to the paragraphs collection.
This article has taught us the process to transform a GIF file into a PDF. For adding Bates numbers to a PDF, refer to the article Add Bates numbers to PDF using C#.