Пример #1
0
        public Byte[] MergDocuments()
        {
            string strdocPath = Server.MapPath("Temp");
            /***Create Temp folder just processing purpose*/
            string outputPath  = Server.MapPath("Output"); // your code goes here
            bool   checkfolder = System.IO.Directory.Exists(outputPath);

            if (!checkfolder)
            {
                System.IO.Directory.CreateDirectory(outputPath);
            }
            /*****End****/
            Byte[] documentcontent = PDFConversion.PDfMer(strdocPath, outputPath);
            Directory.Delete(strdocPath, true);
            Directory.Delete(outputPath, true);
            return(documentcontent);
        }
Пример #2
0
 public void ConvertTOPdf(string Type, string sourcePath, string ExportPath)
 {
     PDFConversion.ConvertTOPdf(Type, sourcePath, ExportPath);
     //switch (Type)
     //{
     //    case "EXCEL":
     //        ExcelToPDF(sourcePath, ExportPath);
     //        break;
     //    case "TEXT":
     //        TextToPdf(sourcePath, ExportPath);
     //        break;
     //    case "DOC":
     //        DocToPdf(sourcePath, ExportPath);
     //        break;
     //    case "IMAGE":
     //        ImageToPDF(sourcePath, ExportPath);
     //        break;
     //    default:
     //        break;
     //}
 }
Пример #3
0
        public bool SaveDocument(Byte[] docbinaryarray, string docname, string docType)
        {
            //try
            //{
            /***Create Temp folder just processing purpose*/
            string strdocPath  = Server.MapPath("Temp");    // your code goes here
            bool   checkfolder = System.IO.Directory.Exists(strdocPath);

            if (!checkfolder)
            {
                System.IO.Directory.CreateDirectory(strdocPath);
            }
            /*****End****/

            strdocPath = strdocPath + "\\" + docname;
            FileStream objfilestream = new FileStream(strdocPath, FileMode.Create, FileAccess.ReadWrite);

            objfilestream.Write(docbinaryarray, 0, docbinaryarray.Length);
            objfilestream.Close();


            string[] file    = strdocPath.Split('.');
            string   PdfFile = file[0];

            if (docType != "pdf")
            {
                PDFConversion.ConvertTOPdf(docType, strdocPath, PdfFile);
                File.Delete(strdocPath);
            }

            return(true);

            //}
            //catch (Exception)
            //{
            //    return true;
            //    //throw;
            //}
        }
Пример #4
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            Service1SoapClient sc = new Service1SoapClient();

            progressBar1.Enabled = true;
            progressBar1.Minimum = 1;
            progressBar1.Maximum = 100;
            progressBar1.Step    = 10;
            progressBar1.PerformStep();


            PdfDocument doc   = new PdfDocument();
            int         count = 0;

            string[] FilenameName;
            /***Final Output file folder***/
            string appPath    = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string exportPath = appPath + "\\Uploads";
            bool   exists     = System.IO.Directory.Exists(exportPath);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(exportPath);
            }

            /****End***/

            /***Create Temp folder just processing purpose*/
            string tempPath    = exportPath + "\\Temp"; // your code goes here
            bool   checkfolder = System.IO.Directory.Exists(tempPath);

            if (!checkfolder)
            {
                System.IO.Directory.CreateDirectory(tempPath);
            }
            /*****End****/
            progressBar1.PerformStep();

            foreach (string item in openFileDialog1.FileNames)
            {
                FilenameName = item.Split('\\');
                string   extension    = Path.GetExtension(FilenameName[FilenameName.Length - 1]).ToLower();
                string   fullfilename = Path.GetFileName(FilenameName[FilenameName.Length - 1]);
                string[] filename     = fullfilename.Split('.');
                string   filePath     = tempPath + "\\" + filename[0];
                if (extension == ".jpg" || extension == ".jpeg" || extension == ".gif")
                {
                    Conversion.PDFConversion.ConvertTOPdf("IMAGE", item, filePath, ref doc, count);
                }
                else if (extension == ".xls" || extension == ".xlsx")
                {
                    // Conversion.PDFConversion.ConvertTOPdf("EXCEL", item, filePath, ref doc, 0);
                    sc.ConvertTOPdf("EXCEL", item, filePath);
                }
                else if (extension == ".txt")
                {
                    Conversion.PDFConversion.ConvertTOPdf("TEXT", item, filePath, ref doc, count);
                }
                else if (extension == ".doc" || extension == ".docx")
                {
                    Conversion.PDFConversion.ConvertTOPdf("DOC", item, filePath, ref doc, 0);
                }
                count++;
            }
            progressBar1.PerformStep();
            Conversion.PDFConversion con = new PDFConversion();
            con.PDfMer(tempPath, exportPath);

            Directory.Delete(tempPath, true);


            progressBar1.Value   = 100;
            progressBar1.Enabled = false;
            progressBar1.PerformStep();
        }
Пример #5
0
 public int GetDocumentLen(string DocumentName)
 {
     return(PDFConversion.GetDocumentLen(DocumentName));
 }
Пример #6
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            /**Progress Bar***/
            progressBar1.Enabled = true;
            progressBar1.Minimum = 1;
            progressBar1.Maximum = 100;
            progressBar1.Step    = 10;
            progressBar1.PerformStep();
            /**End**/

            BasicHttpBinding binding = new BasicHttpBinding();

            binding.MaxBufferPoolSize      = 2147483647;
            binding.MaxBufferSize          = 2147483647;
            binding.MaxReceivedMessageSize = 2147483647;
            string          url     = System.Configuration.ConfigurationSettings.AppSettings["webserviceURL"];
            EndpointAddress address = new EndpointAddress(url);

            Service1SoapClient sc = new Service1SoapClient(binding, address);


            try
            {
                PdfDocument doc   = new PdfDocument();
                int         count = 0;
                string[]    FilenameName;
                string      exportPath = "";
                /***Final Output file folder***/
                if (lblOutpath.Text == "")
                {
                    string appPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                    exportPath = appPath + "\\Uploads";
                    bool exists = System.IO.Directory.Exists(exportPath);
                    if (!exists)
                    {
                        System.IO.Directory.CreateDirectory(exportPath);
                    }
                }
                else
                {
                    exportPath = lblOutpath.Text;
                }
                /****End***/


                progressBar1.PerformStep();

                foreach (string item in openFileDialog1.FileNames)
                {
                    FilenameName = item.Split('\\');
                    string   extension    = Path.GetExtension(FilenameName[FilenameName.Length - 1]).ToLower();
                    string   fullfilename = Path.GetFileName(FilenameName[FilenameName.Length - 1]);
                    string[] filename     = fullfilename.Split('.');
                    if (extension == ".jpg" || extension == ".jpeg" || extension == ".gif")
                    {
                        ConvertFileToStream("IMAGE", item);
                    }
                    else if (extension == ".xls" || extension == ".xlsx")
                    {
                        ConvertFileToStream("EXCEL", item);
                    }
                    else if (extension == ".txt")
                    {
                        ConvertFileToStream("TEXT", item);
                    }
                    else if (extension == ".doc" || extension == ".docx")
                    {
                        ConvertFileToStream("DOC", item);
                    }
                    else if (extension == ".pdf")
                    {
                        ConvertFileToStream("pdf", item);
                    }
                    count++;
                    progressBar1.PerformStep();
                }
                progressBar1.PerformStep();
                Conversion.PDFConversion con = new PDFConversion();


                var documentContents = sc.MergDocuments();
                saveFinalDocuments(documentContents, exportPath);

                progressBar1.Value   = 100;
                progressBar1.Enabled = false;
                progressBar1.PerformStep();
                MessageBox.Show("File Created on location:" + exportPath);
            }
            catch (Exception)
            {
                MessageBox.Show("Error exists during file conversions");
                // throw;
            }
        }