This article describes the method of C# to implement TIF image to PDF file. Share it for your reference. The specific implementation method is as follows:
Here is a description of the usage of TIFtoPDF. This tool can combine multiple TIF image files into one PDF file
Files click hereDownload this site。
The file is as follows:
using System; using ; using ; using ; using ; using ; namespace TIFtoPDF { class Program { //Merge multiple tif files into one pdf file private static void tifToPdf(IEnumerable<string> arr, string sFilePdf) { FileInfo _toFile = new FileInfo(sFilePdf); // Create a document object Document doc = new Document(PageSize.A3, 0, 0, 0, 0); int pages = 0; FileStream fs=new FileStream(sFilePdf,); // Define the output location and load the document object into the output object PdfWriter writer = (doc, fs); // Open the document object (); foreach(string sFileTif in arr) { PdfContentByte cb = ; RandomAccessFileOrArray ra = new RandomAccessFileOrArray(sFileTif); int comps = (ra); for (int c = 0; c < comps; ++c) { Image img = (ra, c + 1); if (img != null) { (7200f / , 7200f / ); (new Rectangle(, img .ScaledHeight)); (0,0); (img); (); ++pages; } } ();// closure } // Close the document object and release the resource (); } public static void Main(string[] args) { tifToPdf(new string[]{@"C:\"},@"C:\"); } } }
I hope this article will be helpful to everyone's C# programming.