XWiki.Office.Word.ConversionManager.ConvertFromWebToWord C# (CSharp) Method

ConvertFromWebToWord() public method

Converts a html source from a Web form to Word compatible format.
public ConvertFromWebToWord ( String content ) : String
content String The html to be converted.
return String
        public String ConvertFromWebToWord(String content)
        {
            states.SetActionState(ConverterActionState.Downloading);
            content = webToLocalHtml.AdaptSource(content);
            states.SetActionState(ConverterActionState.EditingPage);
            return content;
        }

Usage Example

        /// <summary>
        /// Retrieves a page from the wiki and save it locally in order to be merged to the active document.
        /// </summary>
        /// <param name="pageFullName">The full name of the wiki page.</param>
        /// <param name="localFileName">String reference to the file path of the created document.</param>
        private void OpenForMerge(String pageFullName, out String localFileName)
        {
            String content = Client.GetRenderedPageContent(pageFullName);
            String suffix = "__LATEST";
            String folder = addin.AddinSettings.PagesRepository + "TempPages";

            localFileName = pageFullName.Replace(".", "-") + suffix;
            ConvertToNormalFolder(folder);
            ConversionManager pageConverter;
            //TODO: The converter info should be merged.
            pageConverter = new ConversionManager(addin.AddinSettings, addin.serverURL, folder, pageFullName, localFileName, addin.Client);
            //pageConverters.Add(pageFullName + suffix, pageConverter);

            content = pageConverter.ConvertFromWebToWord(content);
            localFileName = folder + "\\" + localFileName + ".html";
            addin.currentLocalFilePath = localFileName;
            StringBuilder pageContent = new StringBuilder(content);
            //Process the content
            pageContent.Insert(0, startDocument);
            pageContent.Append(endDocument);
            //Save the file
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            StreamWriter writer = new StreamWriter(localFileName, false, Encoding.UTF8);
            writer.Write(pageContent.ToString());
            writer.Close();
        }