static void Main(string[] args) { //Convert PNG file to PDF file SautinSoft.PdfVision v = new SautinSoft.PdfVision(); //v.Serial = "XXXXXXXXXXXXXXX"; //specify converting options v.PageStyle.PageSize.Auto(); //v.PageStyle.PageMarginLeft.Inch(1); //v.ImageStyle.Heightmm(150); //v.ImageStyle.WidthInch(10); string inpFile = Path.GetFullPath(@"..\..\image-png.png"); FileInfo outFile = new FileInfo(@"Result.pdf"); int ret = v.ConvertImageFileToPDFFile(inpFile, outFile.FullName); //0 - converting successfully //1 - can't open input file, check the input path //2 - can't create output file, check the output path //3 - converting failed if (ret == 0) { // Open the resulting PDF document in a default PDF Viewer. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile.FullName) { UseShellExecute = true }); } }
public void ConvertirImagenTifaPDF(string INtifPath, string OUTpdfPath) { SautinSoft.PdfVision f = new SautinSoft.PdfVision(); f.Serial = "10360634037"; //Serial develop //f.Serial = "10160735830"; //Serial Server f.ConvertImageFileToPDFFile(INtifPath, OUTpdfPath); }
static void Main(string[] args) { // Convert many TIFF files to PDF files. SautinSoft.PdfVision v = new SautinSoft.PdfVision(); DirectoryInfo inpFolder = new DirectoryInfo(@"..\..\"); FileInfo[] inpFiles = inpFolder.GetFiles(@"*.tif*"); DirectoryInfo outFolder = new DirectoryInfo(Directory.GetCurrentDirectory()).CreateSubdirectory("Results"); foreach (FileInfo inpFile in inpFiles) { string pdfFile = Path.GetFileNameWithoutExtension(inpFile.FullName) + ".pdf"; pdfFile = Path.Combine(outFolder.FullName, pdfFile); v.ConvertImageFileToPDFFile(inpFile.FullName, pdfFile); } // Open the resulting folder with the PDF documents. System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFolder.FullName) { UseShellExecute = true }); }
private void btnProcess_Click(object sender, EventArgs e) { lblTimeElapsed.Text = ""; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); //Convert many TIFF files to PDF files in the same folder SautinSoft.PdfVision v = new SautinSoft.PdfVision(); string tiffPath = imagesFolder; //string[] tiffFiles = Directory.GetFiles(tiffPath, "*.tif"); var fileNames = new List <String>(); foreach (string f in Directory.GetFiles(tiffPath, "*.tif")) { fileNames.Add(f); } fileNames.Sort(); foreach (string tiffFile in fileNames) { v.ConvertImageFileToPDFFile(tiffFile, Path.ChangeExtension(tiffFile, "pdf")); } //Open the folder with PDF //System.Diagnostics.Process.Start(tiffPath); //merge 4 PDF files string[] pdfFiles = Directory.GetFiles(tiffPath, "*.pdf"); int x = 0; foreach (string pdfFile in pdfFiles) { pdfFiles[x] = @pdfFile; x++; } //int ret = v.MergePDFFileArrayToPDFFile(pdfFiles, @"C:\Development\CDLIS\DocImages\AllRows\mergedfiles.pdf"); gImagesFolder = tiffPath + "\\MergedPDF"; Directory.CreateDirectory(gImagesFolder); int ret = v.MergePDFFileArrayToPDFFile(pdfFiles, gImagesFolder + "\\MergedPDFs.pdf"); DirectoryInfo di = new DirectoryInfo(@tiffPath); FileInfo[] files = di.GetFiles("*.pdf").Where(p => p.Extension == ".pdf").ToArray(); foreach (FileInfo file in files) { try { file.Attributes = FileAttributes.Normal; File.Delete(file.FullName); } catch { } } //0 - merged successfully //1 - error, can't merge PDF documents //2 - error, can't create output file, probably it used by another application //3 - merging failed //4 - merged successfully, but some files were not merged //if (ret == 0) //{ // System.Diagnostics.Process.Start(tiffPath + "\\mergedfiles.pdf"); //} watch.Stop(); TimeSpan ts = watch.Elapsed; GlobalVariables.ElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); lblTimeElapsed.Text = GlobalVariables.ElapsedTime; }