public ActionResult Download(string id, string format)
        {
            string LicenseFilePath = ConfigurationManager.AppSettings["LicenseFilePath"];

            if (System.IO.File.Exists(LicenseFilePath))
            {
                GroupDocs.Editor.License license = new GroupDocs.Editor.License(); // Instantiate GroupDocs.Editor license
                license.SetLicense(LicenseFilePath);                               // Apply GroupDocs.Editor license using license path
            }

            Document myDocument = Utils.GetDocument(id);

            WordFormats      saveFormat         = Utils.GetSaveFormat(format);
            string           password           = string.Empty;
            WordsSaveOptions saveOptions        = new WordsSaveOptions(saveFormat, password);
            string           resourcesDirectory = Server.MapPath("/App_Data/Samples");
            string           resultFileName     = myDocument.Name + "." + format;
            string           resultFilePath     = Server.MapPath("/App_Data/Downloads") + "\\" + resultFileName;

            using (OutputHtmlDocument htmlDoc = OutputHtmlDocument.FromMarkup(myDocument.HTML, resourcesDirectory))
            {
                using (System.IO.FileStream outputFile = System.IO.File.Create(resultFilePath))
                {
                    EditorHandler.ToDocument(htmlDoc, outputFile, saveOptions);
                    return(File(resultFilePath, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", resultFileName));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Applies GroupDocs.Editor license using stream input
        /// </summary>
        public static void ApplyLicense(Stream licenseStream)
        {
            // Instantiate GroupDocs.Editor license
            GroupDocs.Editor.License license = new GroupDocs.Editor.License();

            // Apply GroupDocs.Editor license using license file stream
            license.SetLicense(licenseStream);
        }
Esempio n. 3
0
        //ExEnd:CommonProperties

        //ExStart:ApplyLicense
        /// <summary>
        /// Applies GroupDocs.Editor license
        /// </summary>
        public static void ApplyLicense(string filepath)
        {
            // Instantiate GroupDocs.Editor license
            GroupDocs.Editor.License license = new GroupDocs.Editor.License();

            // Apply GroupDocs.Editor license using license path
            license.SetLicense(filepath);
        }