示例#1
0
        // GET api/values
        public IEnumerable <string> Get()
        {
            var mappedPath = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/Docs/");

            var directory = new DirectoryInfo(mappedPath);

            var files = directory.GetFiles("*.docx");

            foreach (var file in files)
            {
                //Loads an existing Word document
                var wordDocument = new WordDocument($"{mappedPath}{file.Name}", FormatType.Docx)
                {
                    //Initializes the ChartToImageConverter for converting charts during Word to pdf conversion
                    ChartToImageConverter = new ChartToImageConverter()
                };

                //Creates an instance of the DocToPDFConverter
                var converter = new DocToPDFConverter();
                //Converts Word document into PDF document
                var pdfDocument = converter.ConvertToPDF(wordDocument);
                //Saves the PDF file
                pdfDocument.Save($"{mappedPath}{file.Name.Replace(file.Extension, "")}.pdf");

                //Closes the instance of document objects
                pdfDocument.Close(true);
                wordDocument.Close();
            }
            return(new string[] { "value1", "value2" });
        }
示例#2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                //folderbrowserdialog для выбора папки
                FolderBrowserDialog folderBrowser = new FolderBrowserDialog();

                // cоздаем конвертер
                DocToPDFConverter converter = new DocToPDFConverter();



                //массив пдф документов
                PdfDocument[] pdfs;

                if (folderBrowser.ShowDialog() == DialogResult.OK)
                {
                    //массив файлов из папки
                    string[] files = Directory.GetFiles(folderBrowser.SelectedPath);

                    progressBar1.Value = 0;

                    progressBar1.Maximum = files.Length;

                    //задаем размеры массива пдф файлов
                    pdfs = new PdfDocument[files.Length];

                    //перебераем в цикле все файлы и конвертируем
                    for (int i = 0; i < files.Length; i++)
                    {
                        if (Path.GetExtension(files[i]) == ".docx")
                        {
                            pdfs[i] = converter.ConvertToPDF(new WordDocument(files[i], FormatType.Docx));

                            progressBar1.Value++;

                            pdfs[i].Save(System.IO.Path.GetDirectoryName(files[i]) + "/" + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".pdf");

                            pdfs[i].Close();
                        }
                        else if (Path.GetExtension(files[i]) == ".doc")
                        {
                            pdfs[i] = converter.ConvertToPDF(new WordDocument(files[i], FormatType.Docx));

                            progressBar1.Value++;
                            pdfs[i].Save(System.IO.Path.GetDirectoryName(files[i]) + "/" + System.IO.Path.GetFileNameWithoutExtension(files[i]) + ".pdf");

                            pdfs[i].Close();
                        }
                    }
                    //освобождаем ресурсы конвертера

                    converter.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Пустой файл!");
            }
        }
示例#3
0
        public ActionResult CloneandMerge(string Group1, string Group2, string ImportOptions)
        {
            if (Group1 == null)
            {
                return(View());
            }
            if (Group2 == null)
            {
                return(View());
            }

            string basePath       = ResolveApplicationDataPath("", "App_Data\\DocIO");
            string sourceFileName = basePath + "Adventure.docx";
            // Opens a source document.
            WordDocument document = new WordDocument(basePath + "Northwind.docx");

            if (Group2 == "UseImportcontents")
            {
                document.ImportContent(new WordDocument(sourceFileName), GetImportOption(ImportOptions));
            }
            else
            {
                //Specifies the import option for the cloning the contents.
                document.ImportOptions = GetImportOption(ImportOptions);
                // Read the source template document
                WordDocument destinationDocument = new WordDocument(sourceFileName);
                // Enumerate all the sections from the source document.
                foreach (IWSection sec in destinationDocument.Sections)
                {
                    // Cloning all the sections one by one and merging it to the destination document.
                    document.Sections.Add(sec.Clone());
                    // Setting section break code to be the same as the template.
                    document.LastSection.BreakCode = sec.BreakCode;
                }
            }
            //Save as .doc format
            if (Group1 == "WordDoc")
            {
                return(document.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .docx format
            else if (Group1 == "WordDocx")
            {
                return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(document);

                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            return(View());
        }
        private void button1_Click(object sender, System.EventArgs e)
        {
            string            text      = @"..\..\..\..\..\..\..\Common\Data\PDF\Essential PDF.rtf";
            WordDocument      wordDoc   = new WordDocument(text);
            DocToPDFConverter converter = new DocToPDFConverter();
            //Convert word document into PDF document
            PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

            //Save the pdf file
            pdfDoc.Save("RTFtoPDF.pdf");
            wordDoc.Close();
            converter.Dispose();
            pdfDoc.Close();
            //Message box confirmation to view the created PDF document.
            if (MessageBox.Show("Do you want to view the PDF file?", "PDF File Created",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                == DialogResult.Yes)
            {
                //Launching the PDF file using the default Application.[Acrobat Reader]
                System.Diagnostics.Process.Start("RTFtoPDF.pdf");
                this.Close();
            }
            else
            {
                // Exit
                this.Close();
            }
        }
示例#5
0
        public ActionResult DOCtoPDF(string button, string renderingMode, string renderingMode1, string renderingMode2, string renderingMode3, string renderingMode4, string renderingMode5, string renderingMode6, string autoTag, string preserveFormFields, string exportBookmarks, string embeddingFont, HttpPostedFileBase file)
        {
            if (button == null)
            {
                return(View());
            }
            //Get input Word document.
            WordDocument document = GetInputWordocument(file);

            if (document != null)
            {
                string output = file == null ? "DoctoPDF" : Path.GetFileNameWithoutExtension(file.FileName);
                //Initialize chart to image converter for converting charts in Word to PDF conversion
                document.ChartToImageConverter             = new ChartToImageConverter();
                document.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;

                DocToPDFConverter converter = new DocToPDFConverter();
                //Enable Direct PDF rendering mode for faster conversion.
                if (renderingMode == "DirectPDF")
                {
                    converter.Settings.EnableFastRendering = true;
                }
                if (renderingMode1 == "PreserveStructureTags")
                {
                    converter.Settings.AutoTag = true;
                }
                if (renderingMode2 == "PreserveFormFields")
                {
                    converter.Settings.PreserveFormFields = true;
                }
                converter.Settings.ExportBookmarks = renderingMode3 == "PreserveWordHeadingsToPDFBookmarks"
                                                       ? Syncfusion.DocIO.ExportBookmarkType.Headings
                                                     : Syncfusion.DocIO.ExportBookmarkType.Bookmarks;
                if (renderingMode4 == "EnablesCompleteFont")
                {
                    converter.Settings.EmbedCompleteFonts = true;
                }
                if (renderingMode5 == "EnablesSubsetFont")
                {
                    converter.Settings.EmbedFonts = true;
                }
                if (renderingMode6 == "ShowRevisions")
                {
                    document.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions;
                }
                //Convert word document into PDF document
                PdfDocument pdfDoc = converter.ConvertToPDF(document);
                try
                {
                    return(pdfDoc.ExportAsActionResult(output + ".pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
                }
                catch (Exception)
                { }
                finally
                {
                }
            }

            return(View());
        }
示例#6
0
        public ActionResult TableStyles(string Group1)
        {
            if (Group1 == null)
            {
                return(View());
            }
            string       dataPath = ResolveApplicationDataPath("TemplateTableStyle.doc", "Data\\DocIO");
            WordDocument document = new WordDocument(dataPath);

            string dataBase = ResolveApplicationDataPath("Northwind.mdb", "Data");

            // Get Data from the Database.
            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
            string          connectionstring = "Data Source = " + ResolveApplicationDataPath("Northwind.mdb", "Data");
            OleDbConnection conn             = new OleDbConnection();

            conn.ConnectionString = "Provider=Microsoft.JET.OLEDB.4.0;Password=\"\";User ID=Admin;" + connectionstring;
            conn.Open();
            DataSet          ds      = new DataSet();
            OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Suppliers", conn);

            adapter.Fill(ds);
            ds.Tables[0].TableName = "Suppliers";
            adapter.Dispose();
            conn.Close();

            // Execute Mail Merge with groups.
            document.MailMerge.ExecuteGroup(ds.Tables[0]);

            #region Built-in table styles
            //Get table to apply style.
            WTable table = (WTable)document.LastSection.Tables[0];

            //Apply built-in table style to the table.
            table.ApplyStyle(BuiltinTableStyle.MediumShading1Accent5);
            #endregion

            #region Document save option
            //Save as .docx format
            if (Group1 == "WordDocx")
            {
                return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(document);

                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            #endregion Document save option

            return(View());
        }
 public HttpResponseMessage ConvertToPdf()
 {
     // Gets input Word document stream from result.
     using (Stream wordStream = Request.Content.ReadAsStreamAsync().Result)
     {
         // Creates new MemoryStream instance for output PDF.
         MemoryStream pdfStream = new MemoryStream();
         using (WordDocument wordDocument = new WordDocument(wordStream))
         {
             // Initializes the ChartToImageConverter for converting charts during Word to PDF conversion.
             wordDocument.ChartToImageConverter             = new ChartToImageConverter();
             wordDocument.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;
             // Creates an instance of the DocToPDFConverter.
             using (DocToPDFConverter docToPdfConverter = new DocToPDFConverter())
             {
                 // Converts Word document into PDF document.
                 using (PdfDocument pdfDocument = docToPdfConverter.ConvertToPDF(wordDocument))
                 {
                     // Saves the PDF document to stream.
                     pdfDocument.Save(pdfStream);
                     pdfStream.Position = 0;
                     pdfDocument.Close(true);
                 }
             }
             // Creates HttpResponseMessage to return result with output PDF stream.
             HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
             result.Content = new StreamContent(pdfStream);
             result.Content.Headers.ContentLength = pdfStream.Length;
             return(result);
         }
     }
 }
示例#8
0
        protected void btnDocToPDF_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName).ToLower();
                if (ext == ".doc" || ext == ".docx")
                {
                    //Convert the input word document to a PDF file
                    # region Convert Doc to PDF
                    Stream readFile = this.FileUpload1.PostedFile.InputStream;
                    try
                    {
                        WordDocument wordDoc = null;
                        if (ext == ".doc")
                        {
                            wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Doc);
                        }
                        else if (ext == ".docx")
                        {
                            wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Docx);
                        }

                        //Initialize chart to image converter for converting charts in word to pdf conversion
                        wordDoc.ChartToImageConverter             = new ChartToImageConverter();
                        wordDoc.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;

                        DocToPDFConverter converter = new DocToPDFConverter();
                        //Enable Direct PDF rendering mode for faster conversion.
                        converter.Settings.EnableFastRendering = chkBox1.Checked;
                        converter.Settings.AutoTag             = CheckBox1.Checked;
                        converter.Settings.PreserveFormFields  = CheckBox2.Checked;
                        converter.Settings.EmbedCompleteFonts  = CheckBox4.Checked;
                        converter.Settings.EmbedFonts          = CheckBox5.Checked;
                        converter.Settings.ExportBookmarks     = CheckBox3.Checked ? Syncfusion.DocIO.ExportBookmarkType.Headings :
                                                                 Syncfusion.DocIO.ExportBookmarkType.Bookmarks;
                        if (CheckBox6.Checked)
                        {
                            wordDoc.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions;
                        }
                        //Convert word document into PDF document
                        PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

                        pdfDoc.Save("DoctoPDF.pdf", Response, HttpReadType.Save);

                        readFile.Close();
                        this.label1.Text = "";
                    }
                    catch (Exception)
                    {
                        this.label1.Text = "The input document could not be processed, Could you please email the document to [email protected] for troubleshooting";
                    }

                    # endregion
                }
                else
                {
                    this.label1.Text = "Please choose doc or docx file to convert to PDF";
                }
            }
示例#9
0
        public ActionResult UpdateFields(string Group1, string Button, string UnlinkFields)
        {
            if (Group1 == null)
            {
                return(View());
            }
            if (Button == "View Template")
            {
                return(new TemplateResult("TemplateUpdateFields.docx", ResolveApplicationDataPath("Data\\DocIO"), HttpContext.ApplicationInstance.Response));
            }

            //Loads the template document.
            WordDocument document = new WordDocument(ResolveApplicationDataPath("TemplateUpdateFields.docx", "Data\\DocIO"));

            //Initialize DataSet object.
            DataSet ds = new DataSet();

            //Load data from the xml document.
            ds.ReadXml(ResolveApplicationDataPath("StockDetails.xml", "Data\\DocIO"));

            // Execute Mail Merge with groups.
            document.MailMerge.ExecuteGroup(ds.Tables["StockDetails"]);

            //Update fields in the document.
            document.UpdateDocumentFields();

            //Unlink the fields in Word document when UnlinkFields is enable.
            if (UnlinkFields == "UnlinkFields")
            {
                UnlinkFieldsInDocument(document);
            }

            #region saveOption
            //Save as .doc format
            if (Group1 == "WordDoc")
            {
                return(document.ExportAsActionResult("Update Fields.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .docx format
            else if (Group1 == "WordDocx")
            {
                return(document.ExportAsActionResult("Update Fields.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(document.ExportAsActionResult("Update Fields.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(document);

                return(pdfDoc.ExportAsActionResult("Update Fields.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            #endregion saveOption
            return(View());
        }
        private void btnconvert_Click_1(object sender, EventArgs e)
        {
            if (this.textBox1.Text != String.Empty)
            {
                WordDocument wordDoc = new WordDocument((string)textBox1.Tag, Syncfusion.DocIO.FormatType.Automatic);
#if !(SyncfusionFramework3_5 || SyncfusionFramework2_0)
                //Initialize chart to image converter for converting charts in word to pdf conversion
                wordDoc.ChartToImageConverter             = new ChartToImageConverter();
                wordDoc.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;
#endif
                DocToPDFConverter converter = new DocToPDFConverter();

                //Enable Direct PDF rendering mode for faster conversion.
                converter.Settings.EnableFastRendering = checkBox1.Checked;
                converter.Settings.EmbedCompleteFonts  = checkBox2.Checked;
                converter.Settings.EmbedFonts          = checkBox3.Checked;
                converter.Settings.AutoTag             = checkBox4.Checked;
                converter.Settings.PreserveFormFields  = checkBox5.Checked;
                converter.Settings.ExportBookmarks     = checkBox6.Checked
                                                     ? Syncfusion.DocIO.ExportBookmarkType.Headings
                                                     : Syncfusion.DocIO.ExportBookmarkType.Bookmarks;

                if (checkBox7.Checked)
                {
                    wordDoc.RevisionOptions.ShowMarkup = RevisionType.Deletions | RevisionType.Formatting | RevisionType.Insertions;
                }
                //Convert word document into PDF document
                PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
                //Save the pdf file
                pdfDoc.Save("DoctoPDF.pdf");
                //Message box confirmation to view the created document.
                if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    try
                    {
#if NETCORE
                        System.Diagnostics.Process process = new System.Diagnostics.Process();
                        process.StartInfo = new System.Diagnostics.ProcessStartInfo("DoctoPDF.pdf")
                        {
                            UseShellExecute = true
                        };
                        process.Start();
#else
                        System.Diagnostics.Process.Start("DoctoPDF.pdf");
#endif
                        //Exit
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                MessageBoxAdv.Show("Browse a word document and click the button to convert as a PDF.");
            }
        }
示例#11
0
        protected PdfDocument ConvertToPDF(WordDocument document)
        {
            DocToPDFConverter converter = new DocToPDFConverter();
            //Convert the Word document into a PDF document.
            PdfDocument pdfDoc = converter.ConvertToPDF(document);

            return(pdfDoc);
        }
        public ActionResult MailMergeEvent(string Group1, string Button)
        {
            if (Group1 == null)
            {
                return(View());
            }
            if (Button == "View Template")
            {
                return(new TemplateResult("Template.doc", ResolveApplicationDataPath("App_Data\\DocIO"), HttpContext.ApplicationInstance.Response));
            }

            try
            {
                // Load the template.
                WordDocument document = new WordDocument(ResolveApplicationDataPath("Template.doc", "App_Data\\DocIO"));

                // Get the tables from Data Set.
                GetDataTable();

                // Using Merge events to do conditional formatting during runtime.
                document.MailMerge.MergeField      += new MergeFieldEventHandler(AlternateRows_MergeField);
                document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MergeField_ProductImage);

                // Execute Mail Merge with groups.
                document.MailMerge.ExecuteGroup(ds.Tables["Products"]);
                document.MailMerge.ExecuteGroup(ds.Tables["Product_PriceList"]);
                //Save as .doc format
                if (Group1 == "WordDoc")
                {
                    return(document.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                }
                //Save as .docx format
                else if (Group1 == "WordDocx")
                {
                    return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                }
                // Save as WordML(.xml) format
                else if (Group1 == "WordML")
                {
                    return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
                }
                //Save as .pdf format
                else if (Group1 == "Pdf")
                {
                    DocToPDFConverter converter = new DocToPDFConverter();
                    PdfDocument       pdfDoc    = converter.ConvertToPDF(document);

                    return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
                }
            }
            catch (Exception Ex)
            {
                System.Diagnostics.Trace.WriteLine(Ex.Message + "\n\n\n" + Ex.StackTrace);
            }
            return(View());
        }
示例#13
0
        private static bool ConvertorDOC(string filename, string pdf_filename)
        {
            WordDocument      word_document = new WordDocument(filename);
            DocToPDFConverter converter     = new DocToPDFConverter();
            PdfDocument       pdf_document  = converter.ConvertToPDF(word_document);

            pdf_document.Save(pdf_filename);
            pdf_document.Close(true);
            return(true);
        }
示例#14
0
        protected void btnDocToRTF_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName).ToLower();
                if (ext == ".doc" || ext == ".docx")
                {
                    //Convert the input word document to a PDF file
                    # region Convert Doc to PDF
                    Stream readFile = this.FileUpload1.PostedFile.InputStream;
                    try
                    {
                        WordDocument wordDoc = null;
                        if (ext == ".doc")
                        {
                            wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Doc);
                        }
                        else if (ext == ".docx")
                        {
                            wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Docx);
                        }

                        //Initialize chart to image converter for converting charts in word to pdf conversion
                        wordDoc.ChartToImageConverter             = new ChartToImageConverter();
                        wordDoc.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;


                        DocToPDFConverter converter = new DocToPDFConverter();
                        //Convert word document into PDF document
                        PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

                        //Save the pdf file
                        if (this.CheckBox1.Checked)
                        {
                            pdfDoc.Save("DoctoPDF.pdf", Response, HttpReadType.Open);
                        }
                        else
                        {
                            pdfDoc.Save("DoctoPDF.pdf", Response, HttpReadType.Save);
                        }

                        readFile.Close();
                        this.label1.Text = "";
                    }
                    catch (Exception)
                    {
                        this.label1.Text = "The input document could not be processed, Could you please email the document to [email protected] for troubleshooting";
                    }
                    # endregion
                }
                else
                {
                    this.label1.Text = "Please choose doc or docx file to convert to PDF";
                }
            }
示例#15
0
        public ActionResult HeaderandFooter(string Group1)
        {
            if (Group1 == null)
            {
                return(View());
            }

            // Creating a new document.
            WordDocument doc = new WordDocument();
            // Add a new section to the document.
            IWSection section1 = doc.AddSection();

            // Set the header/footer setup.
            section1.PageSetup.DifferentFirstPage = true;
            // Inserting Header Footer to first page
            InsertFirstPageHeaderFooter(doc, section1);
            // Inserting Header Footer to all pages
            InsertPageHeaderFooter(doc, section1);

            // Add text to the document body section.
            IWParagraph par;

            par = section1.AddParagraph();

            //Insert Text into the word Document.
            StreamReader reader = new StreamReader(ResolveApplicationDataPath("WinFAQ.txt", "App_Data\\DocIO"), System.Text.Encoding.ASCII);
            string       text   = reader.ReadToEnd();

            par.AppendText(text);

            //Save as .doc format
            if (Group1 == "WordDoc")
            {
                return(doc.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .docx format
            else if (Group1 == "WordDocx")
            {
                return(doc.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(doc.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(doc);

                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            return(View());
        }
示例#16
0
        public bool ConvertToPDF(string inputFile, string outputFile)
        {
            bool   converted = false;
            string extension = Path.GetExtension(inputFile);

            try
            {
                // Convert using SyncFusion.
                WordDocument wordDocument = new WordDocument();

                //Loads an existing Word document
                if (extension.ToUpper() == ".DOC")
                {
                    wordDocument = new WordDocument(inputFile, FormatType.Doc);
                }
                if (extension.ToUpper() == ".DOCX")
                {
                    wordDocument = new WordDocument(inputFile, FormatType.Docx);
                }
                if (extension.ToUpper() == ".DOT")
                {
                    wordDocument = new WordDocument(inputFile, FormatType.Dot);
                }

                //Initializes the ChartToImageConverter for converting charts during Word to pdf conversion
                wordDocument.ChartToImageConverter = new ChartToImageConverter();

                //Creates an instance of the DocToPDFConverter
                DocToPDFConverter converter = new DocToPDFConverter();

                //set PDF conformance level using DocToPDFConverterSettings class property.
                //converter.Settings.PdfConformanceLevel = PdfConformanceLevel.None;
                converter.Settings.PdfConformanceLevel = PdfConformanceLevel.Pdf_A1B;

                //Converts Word document into PDF document
                //PdfDocument pdfDocument = new PdfDocument(PdfConformanceLevel.Pdf_A1B);
                PdfDocument pdfDocument = new PdfDocument();
                pdfDocument = converter.ConvertToPDF(wordDocument);

                //Saves the PDF file
                pdfDocument.Save(outputFile);

                //Closes the instance of document objects
                pdfDocument.Close(true);
                wordDocument.Close();

                converted = true;
            }
            catch (Exception)
            {
                throw;
            }

            return(converted);
        }
        public void ExportToPDF()
        {
            string            RTEID       = HttpContext.Current.Request.QueryString["rteid"];
            string            FileName    = HttpContext.Current.Request.Params[RTEID + "_inputFile"];
            string            htmlText    = HttpContext.Current.Request.Params[RTEID + "_inputVal"];
            WordDocument      document    = GetDocument(htmlText);
            DocToPDFConverter converter   = new DocToPDFConverter();
            PdfDocument       pdfDocument = converter.ConvertToPDF(document);

            pdfDocument.Save(FileName + ".pdf", HttpContext.Current.Response, HttpReadType.Save);
        }
示例#18
0
        /// <summary>
        /// Get pdf stream for creating pdf dcoument
        /// </summary>
        /// <returns></returns>
        private MemoryStream GetPDFStream()
        {
            MemoryStream docIoWordMemoryStream = new MemoryStream();
            MemoryStream docIoPdfMemoryStream  = new MemoryStream();

            _documentTemplate.Save(docIoWordMemoryStream, FormatType.Doc);
            DocToPDFConverter converter = new DocToPDFConverter();

            Syncfusion.Pdf.PdfDocument pdfdoc = converter.ConvertToPDF(docIoWordMemoryStream);
            pdfdoc.Save(docIoPdfMemoryStream);
            return(docIoPdfMemoryStream);
        }
        public ActionResult RTL(string Group1)
        {
            if (Group1 == null)
            {
                return(View());
            }
            // Creating a new document.
            WordDocument document = new WordDocument();

            document.EnsureMinimal();

            // Reading Arabic text from text file.
            StreamReader s    = new StreamReader(ResolveApplicationDataPath("Arabic.txt", "Data\\DocIO"), System.Text.Encoding.ASCII);
            string       text = s.ReadToEnd();

            // Appending Arabic text to the document.
            document.LastParagraph.ParagraphFormat.Bidi = true;
            IWTextRange txtRange = document.LastParagraph.AppendText(text);

            txtRange.CharacterFormat.Bidi = true;

            // Set the RTL text font size.
            txtRange.CharacterFormat.FontSizeBidi = 16;

            #region Document save option
            //Save as .doc format
            if (Group1 == "WordDoc")
            {
                return(document.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .docx format
            else if (Group1 == "WordDocx")
            {
                return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (Group1 == "WordML")
            {
                return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (Group1 == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(document);
                document.Close();
                converter.Dispose();
                return(pdfDoc.ExportAsActionResult("Sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
            #endregion Document save option
            return(View());
        }
示例#20
0
        public ActionResult Default(int id, string SaveOption, string Button)
        {
            if (Button == "View Template")
            {
                return(new TemplateResult("SalesInvoiceDemo.doc", ResolveApplicationDataPath("App_Data\\DocIO"), HttpContext.ApplicationInstance.Response));
            }

            string dataPath1 = ResolveApplicationDataPath("", "App_Data\\DocIO");
            // Create a new document
            WordDocument doc = new WordDocument();

            // Load the template.
            doc.Open((System.IO.Path.Combine(dataPath1, @"SalesInvoiceDemo.doc")), FormatType.Automatic);
            // Execute Mail Merge with groups.
            doc.MailMerge.ExecuteGroup(GetTestOrder(id));
            doc.MailMerge.ExecuteGroup(GetTestOrderTotals(id));

            // Using Merge events to do conditional formatting during runtime.
            doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);

            DataView orderDetails = new DataView(GetTestOrderDetails(id));

            orderDetails.Sort = "ExtendedPrice DESC";
            doc.MailMerge.ExecuteGroup(orderDetails);
            //Save as .doc format
            if (SaveOption == "WordDoc")
            {
                return(doc.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .docx format
            else if (SaveOption == "WordDocx")
            {
                return(doc.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            // Save as WordML(.xml) format
            else if (SaveOption == "WordML")
            {
                return(doc.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment));
            }
            //Save as .pdf format
            else if (SaveOption == "Pdf")
            {
                DocToPDFConverter converter = new DocToPDFConverter();
                PdfDocument       pdfDoc    = converter.ConvertToPDF(doc);

                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }

            return(View());
        }
示例#21
0
        private void btnTopdf_Click(object sender, RoutedEventArgs e)
        {
            if (this.textBox1.Text != String.Empty && fullPath != string.Empty)
            {
                if (this.textBox1.Text.Contains("//"))
                {
                    fullPath = this.textBox1.Text;
                }

                if (File.Exists(fullPath))
                {
                    WordDocument wordDoc = new WordDocument(fullPath);
#if !SyncfusionFrameWork3_5
                    //Initializing chart to image convertor to convert charts in word to pdf conversion
                    wordDoc.ChartToImageConverter             = new ChartToImageConverter();
                    wordDoc.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;
#endif
                    DocToPDFConverter converter = new DocToPDFConverter();
                    //Convert word document into PDF document
                    PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
                    //Save the pdf file
                    pdfDoc.Save("WordtoPDF.pdf");
                    //Message box confirmation to view the created document.
                    if (MessageBox.Show("Conversion Successful. Do you want to view the PDF File?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        try
                        {
                            System.Diagnostics.Process.Start(@"WordtoPDF.pdf");
                            //Exit
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                        }
                    }
                }

                else
                {
                    MessageBox.Show("File doesn’t exist");
                }
            }

            else
            {
                MessageBox.Show("Browse a Word document to convert to RTF", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
示例#22
0
        private void btnTopdf_Click(object sender, RoutedEventArgs e)
        {
            if (this.textBox1.Text != String.Empty && fullPath != string.Empty)
            {
                if (this.textBox1.Text.Contains("//"))
                {
                    fullPath = this.textBox1.Text;
                }

                if (File.Exists(fullPath))
                {
                    WordDocument wordDoc = new WordDocument(fullPath);

                    DocToPDFConverter converter = new DocToPDFConverter();
                    //Convert word document into PDF document
                    PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
                    //Save the pdf file
                    pdfDoc.Save("WordtoPDF.pdf");
                    //Message box confirmation to view the created document.
                    if (MessageBox.Show("Conversion Successful. Do you want to view the PDF File?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
                        try
                        {
                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo = new System.Diagnostics.ProcessStartInfo("WordtoPDF.pdf")
                            {
                                UseShellExecute = true
                            };
                            process.Start();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                        }
                    }
                }

                else
                {
                    MessageBox.Show("File doesn’t exist");
                }
            }

            else
            {
                MessageBox.Show("Browse a Word document to convert to PDF", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }
        public void ExportToPDF()
        {
            string RTEID    = HttpContext.Request.QueryString["rteid"];
            string FileName = HttpContext.Request.Params[RTEID + "_inputFile"];
            string htmlText = HttpContext.Request.Params[RTEID + "_inputVal"];

            foreach (var item in DecodeKey())
            {
                htmlText = htmlText.Replace(item.Key, item.Value);
            }
            WordDocument      document    = GetDocument(htmlText);
            DocToPDFConverter converter   = new DocToPDFConverter();
            PdfDocument       pdfDocument = converter.ConvertToPDF(document);

            pdfDocument.Save(FileName + ".pdf", System.Web.HttpContext.Current.Response, HttpReadType.Save);
        }
示例#24
0
        static void Main(string[] args)
        {
            ITLA_PE_MVC.DATA.ORBIPEEntities db = new ITLA_PE_MVC.DATA.ORBIPEEntities();

            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("Mjk2MjIxQDMxMzgyZTMyMmUzMEg0V3UzZWxVcmhtSFZxZjNHMm01cGc2ajdwSmlTY2prYzJ3VGtLUTdINVk9");


            var cartas = db.UspRegistroParaEnviarCarta();

            foreach (var carta in cartas.Take(5))
            {
                WordDocument doc = new WordDocument(@"C:\Users\luism\Documents\GitHub\ITLA\ModificadaDIC2020CartadeAdmitidos.docx");



                doc.Replace("{ESTUDIANTE}", carta.ESTUDIANTE, false, false);
                doc.Replace("{MATRICULA}", carta.MATRICULA, false, false);
                doc.Replace("{CARRERA}", carta.CARRERA, false, false);
                doc.Replace("{FECHACONVOCATORIA}", carta.FECHACONVOCATORIA, false, false);
                doc.Replace("{FECHANUEGOINGRESO}", carta.FECHANUEGOINGRESO, false, false);
                doc.Replace("{FECHAAMBIENTACION}", carta.FECHAAMBIENTACION, false, false);
                doc.Replace("{FECHAINICIODOCENCIA}", carta.FECHAINICIODOCENCIA, false, false);
                doc.Replace("{FECHAPERIODO}", carta.FECHAPERIODO, false, false);
                doc.Replace("{FECHA}", carta.FECHA, false, false);


                DocToPDFConverter converter = new DocToPDFConverter();
                //Converts Word document into PDF documents
                PdfDocument pdfDocument = converter.ConvertToPDF(doc);

                //string originalURL = "~/ContratosGenerados/" + Guid.NewGuid().ToString() + ".pdf";
                string fileName = @"C:\Users\luism\Documents\GitHub\ITLA\SALIDA\" + carta.MATRICULA + ".pdf";


                pdfDocument.Save(fileName);
                //Closes the instance of document objects
                pdfDocument.Close(true);
                doc.Close();

                doc.Close();


                Console.WriteLine(carta.ESTUDIANTE);
            }

            Console.ReadLine();
        }
        private void btnconvert_Click_1(object sender, EventArgs e)
        {
            if ((string)this.textBox1.Tag != String.Empty)
            {
                WordDocument wordDoc = new WordDocument((string)textBox1.Tag);
#if !SyncfusionFrameWork3_5
                //Initialize chart to image converter for converting charts in word to pdf conversion
                wordDoc.ChartToImageConverter             = new ChartToImageConverter();
                wordDoc.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;
#endif
                DocToPDFConverter converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
                //Save the pdf file
                pdfDoc.Save("WordToPDF.pdf");

                //Message box confirmation to view the created document.
                if (MessageBox.Show("Do you want to view the PDF file?", "File has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    try
                    {
#if NETCORE
                        System.Diagnostics.Process process = new System.Diagnostics.Process();
                        process.StartInfo = new System.Diagnostics.ProcessStartInfo(@"WordToPDF.pdf")
                        {
                            UseShellExecute = true
                        };
                        process.Start();
#else
                        System.Diagnostics.Process.Start(@"WordToPDF.pdf");
#endif
                        //Exit
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("Browse a word document and click the button to convert as a PDF.");
            }
        }
示例#26
0
        protected void PdfExport_Click(object sender, ImageClickEventArgs e)
        {
            string filename = this.PathName;
            string filePath = ResolvePath(filename);

            //Open the word document.
            WordDocument wordDoc = new WordDocument(filePath);

            DocToPDFConverter converter = new DocToPDFConverter();

            //Convert word document into PDF document
            PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

            string path = Path.GetFileNameWithoutExtension(filename).Replace(" ", "_");

            //Saves the pdf document
            pdfDoc.Save(path + ".pdf", Response, HttpReadType.Save);
        }
        public ActionResult DoctoPDF(string InsideBrowser)
        {
            Stream            readFile  = new FileStream(ResolveApplicationDataPath(@"DoctoPDF.doc"), FileMode.Open, FileAccess.Read, FileShare.Read);
            WordDocument      wordDoc   = new WordDocument(readFile);
            DocToPDFConverter converter = new DocToPDFConverter();
            //Convert word document into PDF document
            PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

            //Save the pdf file
            if (InsideBrowser == "Browser")
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Open));
            }
            else
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
        }
示例#28
0
        bool convertWordToPDF(string source, string destination)
        {
            WordDocument document = new WordDocument(source);

            //Initialize chart to image converter for converting charts in Word to PDF conversion
            document.ChartToImageConverter             = new ChartToImageConverter();
            document.ChartToImageConverter.ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal;

            DocToPDFConverter converter = new DocToPDFConverter();

            //Enable Direct PDF rendering mode for faster conversion.
            //if (renderingMode == "DirectPDF")
            //    converter.Settings.EnableFastRendering = true;
            //if (renderingMode1 == "PreserveStructureTags")
            //    converter.Settings.AutoTag = true;
            //if (renderingMode2 == "PreserveFormFields")
            //    converter.Settings.PreserveFormFields = true;
            //converter.Settings.ExportBookmarks =
            //renderingMode3 == "PreserveWordHeadingsToPDFBookmarks"
            //?
            //Syncfusion.DocIO.ExportBookmarkType.Headings
            //:
            //    Syncfusion.DocIO.ExportBookmarkType.Bookmarks;
            //if (renderingMode4 == "EnablesCompleteFont")
            //    converter.Settings.EmbedCompleteFonts = true;
            //if (renderingMode5 == "EnablesSubsetFont")
            //    converter.Settings.EmbedFonts = true;
            //Convert word document into PDF document


            try
            {
                PdfDocument pdfDoc = converter.ConvertToPDF(document);
                pdfDoc.Save(destination);
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
            }
            return(true);
        }
示例#29
0
        private void WriteCoverLetter(CompanyCredentials company, string path)
        {
            WordDocument docToRead = new WordDocument(String.Format("{0}/CoverLetterVladimirVrucinic.docx", rootWritePath));

            docToRead.ReplaceDataInDocument("{company}", company.Name);
            docToRead.Replace("{date}", DateTime.Now.ToString("MMMM dd, yyyy"), true, false);
            docToRead.ReplaceHrData(company.NameHR);

            docToRead.ReplaceDataInDocument("{city}", company.CompanyAddress.City);
            docToRead.ReplaceAddress(company.CompanyAddress.Address);

            DocToPDFConverter converter   = new DocToPDFConverter();
            PdfDocument       pdfDocument = converter.ConvertToPDF(docToRead);

            pdfDocument.Save(String.Format("{0}/CoverLetterVladimirVrucinic.pdf", path));

            pdfDocument.Close(true);
            docToRead.Close();
        }
示例#30
0
        public ActionResult RTFtoPDF(string InsideBrowser)
        {
            string            text      = ResolveApplicationDataPath("Essential PDF.rtf");
            WordDocument      wordDoc   = new WordDocument(text);
            DocToPDFConverter converter = new DocToPDFConverter();
            //Convert word document into PDF document
            PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);

            wordDoc.Close();
            converter.Dispose();
            //Stream the output to the browser.
            if (InsideBrowser == "Browser")
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Open));
            }
            else
            {
                return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save));
            }
        }
        private void buttonSend_Click(object sender, EventArgs e)
        {
            if (_checkedDocument)
            {

            }
            else
            {
                MessageBox.Show("No Documents Selected",
                  "No Documents Selected", MessageBoxButtons.OK,
                  MessageBoxIcon.Exclamation);
                KillWordForWindows();
                Application.Exit();
                return;
            }

            util = new MSUtils();

            if (ckdocument1.Checked == true)
            {

                File.Copy(_document1Path, Application.StartupPath + "\\temp1\\document1.doc",true );

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document1.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document1.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document1.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document1" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document1" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose(); 
            }
            if (ckdocument2.Checked == true)
            {

                File.Copy(_document2Path, Application.StartupPath + "\\temp1\\document2.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document2.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document2.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document2.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document2" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document2" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument3.Checked == true)
            {

                File.Copy(_document3Path, Application.StartupPath + "\\temp1\\document3.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document3.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document3.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document3.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document3" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document3" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument4.Checked == true)
            {
                File.Copy(_document4Path, Application.StartupPath + "\\temp1\\document4.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document4.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document4.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document4.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document4" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document4" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument5.Checked == true)
            {

                File.Copy(_document5Path, Application.StartupPath + "\\temp1\\document5.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document5.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document5.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document5.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document5" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document5" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument6.Checked == true)
            {

                File.Copy(_document6Path, Application.StartupPath + "\\temp1\\document6.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document6.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document6.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document6.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document6" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document6" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument7.Checked == true)
            {

                File.Copy(_document7Path, Application.StartupPath + "\\temp1\\document7.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document7.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document7.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document7.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document7" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document7" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument8.Checked == true)
            {

                File.Copy(_document8Path, Application.StartupPath + "\\temp1\\document8.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document8.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document8.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document8.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document8" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document8" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument9.Checked == true)
            {

                File.Copy(_document9Path, Application.StartupPath + "\\temp1\\document9.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document9.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document9.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document9.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document9" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document9" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }
            if (ckdocument10.Checked == true)
            {

                File.Copy(_document10Path, Application.StartupPath + "\\temp1\\document10.doc", true);

                Stream _readFile = new FileStream(Application.StartupPath + "\\temp1\\document10.doc", FileMode.Open, FileAccess.Read, FileShare.Read);
                WordDocument _wordDocument = new WordDocument(_readFile);
                DocToPDFConverter _converter = new DocToPDFConverter();
                //Convert word document into PDF document
                PdfDocument _pdfDocument = _converter.ConvertToPDF(_wordDocument);
                _pdfDocument.Save(Application.StartupPath + "\\temp1\\document10.pdf");

                PDFFile _file =
                    PDFFile.Open(Application.StartupPath + "\\temp1\\document10.pdf");

                _file.SerialNumber = "PDFVW-Y11DV-6VYTH-TWHXK-6DRLB-7MNQB";

                for (int i = 0; i < _file.PageCount; i++)
                {
                    // Convert each page to bitmap and save it.
                    Bitmap pageImage = _file.GetPageImage(i, 96);
                    pageImage.Save(Application.StartupPath + "\\temp2\\document10" + i.ToString() + ".tif", ImageFormat.Tiff);
                    _listOfTifs.Add(Application.StartupPath + "\\temp2\\document10" + i.ToString() + ".tif");
                }

                _file.Dispose();
                _readFile.Close();
                _readFile.Dispose();
            }

            //util.ConvertToMultiPageTiff(_listOfTifs,_ftpfolder + "\\newtif.tif");
            util.ConvertToMultiPageTiff(_listOfTifs, Application.StartupPath + "\\temp2\\newtif.tif");

            try
            {
                File.Copy(Application.StartupPath + "\\temp2\\newtif.tif", "\\\\hmdn-notes.ct-ortho.com\\YHP-Notes\\" + _fileName + ".tif", true);

                UpdateAppointmentTable(_chargeSlipNumber);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message,
                  "Problem Copying File", MessageBoxButtons.OK,
                  MessageBoxIcon.Exclamation);
            }

            try
            {
                KillWordForWindows();
            }
            catch { }


            MessageBox.Show("Files Moved",
              "Done", MessageBoxButtons.OK,
              MessageBoxIcon.Exclamation);

            Application.Exit();  
        }