Exemplo n.º 1
0
        public HttpResponseMessage MailMerge([FromBody] ExportData exportData)
        {
            Byte[]       data   = Convert.FromBase64String(exportData.documentData.Split(',')[1]);
            MemoryStream stream = new MemoryStream();

            stream.Write(data, 0, data.Length);
            stream.Position = 0;
            try
            {
                Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(stream, Syncfusion.DocIO.FormatType.Docx);
                document.MailMerge.RemoveEmptyGroup      = true;
                document.MailMerge.RemoveEmptyParagraphs = true;
                document.MailMerge.ClearFields           = true;
                document.MailMerge.Execute(CustomerDataModel.GetAllRecords());
                document.Save(stream, Syncfusion.DocIO.FormatType.Docx);
            }
            catch (Exception)
            { }
            string          sfdtText     = "";
            EJ2WordDocument worddocument = EJ2WordDocument.Load(stream, Syncfusion.EJ2.DocumentEditor.FormatType.Docx);

            sfdtText = Newtonsoft.Json.JsonConvert.SerializeObject(worddocument);
            worddocument.Dispose();
            return(new HttpResponseMessage()
            {
                Content = new StringContent(sfdtText)
            });
        }
Exemplo n.º 2
0
        public void SaveSFDT(int id)
        {
            DTO_CUS_DOC_File item = BS_CUS_DOC_File.get_CUS_DOC_File(db, PartnerID, id, true);

            if (item == null)
            {
                return;
            }

            string path = System.Web.HttpContext.Current.Server.MapPath("~");

            item.ModifiedDate = DateTime.Now;
            string version = ".V" + item.ModifiedDate.ToString("yyMMdd-HHmmss");

            int    index  = item.Path.LastIndexOf(".V") == -1 ? item.Path.LastIndexOf(".") : item.Path.LastIndexOf(".V");
            string fileID = item.Path.Substring(0, index);

            string newFilePath = fileID + version + ".docx";
            string pdfFIlePath = fileID + version + ".pdf";

            System.Web.HttpPostedFile         file     = System.Web.HttpContext.Current.Request.Files[0];
            Syncfusion.DocIO.DLS.WordDocument document = new Syncfusion.DocIO.DLS.WordDocument(file.InputStream);

            document.Save(path + newFilePath);
            document.Close();

            convertWordToPDF(path + newFilePath, path + pdfFIlePath);

            item.ModifiedBy = Username;


            item.Code      = pdfFIlePath;
            item.Path      = newFilePath;
            item.Extension = "docx";
            item.FileSize  = new System.IO.FileInfo(path + newFilePath).Length;

            Put(id, item);
        }
        public RadDocument ImportDocx(string filename)
        {
            RadDocument document = null;
            Syncfusion.DocIO.DLS.WordDocument document1 = new Syncfusion.DocIO.DLS.WordDocument();
            document1.Open(filename, FormatType.Doc);
            document1.Save(filename + "x", FormatType.Docx);

            Telerik.WinControls.RichTextBox.FormatProviders.
                IDocumentFormatProvider provider = 
                new Telerik.WinControls.RichTextBox.FileFormats.OpenXml.Docx.DocxFormatProvider();

            using (FileStream stream = new FileStream(filename + "x", FileMode.Open))
            {
                document = provider.Import(stream);
            }
            return document;
        }