Esempio n. 1
0
        static void Main(string[] args)
        {
            // Merge PDF files.
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();

            //v.Serial = "XXXXXXXXXXXXXXX";

            // Let's merge several PDF files.
            string[] inpFiles = new string[] { @"..\..\simple text.pdf", @"..\..\table.pdf" };
            FileInfo outFile  = new FileInfo(@"Result.pdf");

            int ret = v.MergePDFFileArrayToPDFFile(inpFiles, outFile.FullName);

            // 0 - Merged successfully.
            // 1 - Error, can't merge PDF documents.
            // 2 - Error, can't create the output file, probably it used by another application.
            // 3 - Merging failed.
            // 4 - Merged successfully, but some files were not merged.
            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
                });
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Merge PDF files
            SautinSoft.PdfVision v = new SautinSoft.PdfVision();

            //merge 3 PDF files
            string[] files = new string[3];
            files[0] = @"d:\Tempos\image1.pdf";
            files[1] = @"d:\Tempos\image2.pdf";
            files[2] = @"d:\Tempos\image3.pdf";

            // You may download the latest version of SDK here:
            // www.sautinsoft.com/products/convert-html-pdf-and-tiff-pdf-asp.net/download.php
            int ret = v.MergePDFFileArrayToPDFFile(files, @"D:\Tempos\hardcopy.pdf");

            //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
        }
Esempio n. 3
0
        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;
        }