Now, let's see how to append (TIFF/TIF) images to PDF document in C# class application. This example shows the way of adding and merging images to PDF file that is loaded from local file. In general, you can merge and append one image or multiple images to PDF file at a time.
using System; using PQScan.ImageToPDF; namespace AppendImageToPDF { class Program { static void Main(string[] args) { // Create an instance of PQScan.ImageToPDF.PDFConverter object. PDFConverter converter = new PDFConverter(); // Choose PDF page layout. A4 is the most widely used layout. converter.PageSizeType = PageSizeMode.A4; // Set input Tiff images (with single page) from local files. string[] imgFiles = new string[3] { "append1.tif", "append2.tif" , "append3.tif" }; // Name the output PDF file. string outFile = "merge-image-to-pdf.pdf"; // Append Tiff images to PDF document. converter.AppendToPDF(imgFiles, outFile); } } }
The C# class coding example above introduces how to add image from local disk to PDF file. Sometimes, source images may be in stream. So here, we also provide a solution for appending (BMP) image from stream to PDF document using C#.NET.
using System; using System.IO; using PQScan.ImageToPDF; namespace AppendImageToPDF { class Program { static void Main(string[] args) { // Create an instance of PQScan.ImageToPDF.PDFConverter object. PDFConverter converter = new PDFConverter(); // Select PDF page layout. If ImageSize is selected, // PDF page will retain source image size with original quality. converter.PageSizeType = PageSizeMode.ImageSize; // Set input BMP images from file streams. FileStream[] streams = new FileStream[3]; streams[0] = new FileStream("append1.bmp", FileMode.Open); streams[1] = new FileStream("append2.bmp", FileMode.Open); streams[2] = new FileStream("append3.bmp", FileMode.Open); // Set output PDF file name. string outFile = "merge-image-to-pdf.pdf"; // Append BMP images to PDF. converter.AppendToPDF(streams, outFile); } } }