The following C# code gives you an example of rendering and converting PDF to gif image using pqScan PDFToImage SDK.
using System; using System.Drawing; using System.Drawing.Imaging; using PQScan.PDFToImage; namespace PDF2GIF { class Program { static void Main(string[] args) { // Create an instance of PQScan.PDFToImage.PDFDocument object. PDFDocument pdfDoc = new PDFDocument(); // Load a PDF document. pdfDoc.LoadPDF("sample.pdf"); // Get its page count. int count = pdfDoc.PageCount; for (int i = 0; i < count; i++) { // Change PDF page to image. Bitmap gifImage = pdfDoc.ToImage(i); // Save image as gif image format. gifImage.Save("output" + i + ".gif", ImageFormat.Gif); } } } }
In the following C# programming tutorial, you will see how to perform the feature of turning PDF file to Gif image with a target size in C# .NET application.
using System; using System.IO; using System.Drawing; using System.Drawing.Imaging; using PQScan.PDFToImage; namespace PDFToGIF { class Program { static void Main(string[] args) { // Make a new instance of PQScan.PDFToImage.PDFDocument object. PDFDocument pdf = new PDFDocument(); // Create a file stream with PDF information. FileStream stream = new FileStream("sample.pdf", FileMode.Open); // Load PDF document from file stream. pdf.LoadPDF(stream); // Set a target width for gif image. int width = pdf.GetPageWidth(0) / 2; // Set a target height for gif image. int height = pdf.GetPageHeight(0) / 2; // Convert the first page of PDF file to image with the desired size. Bitmap gif = pdf.ToImage(0, width, height); // Save image to gif format. gif.Save("result.gif", ImageFormat.Gif); } } }
Here's a useful online guide that you may read, C#.NET guide: how to set output image converted from PDF, which describes how to customize GIF image size and quality by changing DPI, as well as resetting its width and height.