利用Aspose.Words将html转成pdf和将html转成word
html转成word
/// <summary> /// html转word文件需要先创建一个模板word,再指定新的word文件的地址 /// </summary> /// <param name="templatePath">加密采用的编码方式</param> /// <param name="newFilePath">加密采用的编码方式</param> /// <param name="html">待加密的明文</param> /// <returns></returns> public static void HtmlToWord(string templatePath, string newFilePath, string html) { //加载word模板。 Aspose.Words.Document doc = new Aspose.Words.Document(string.Format(@"{0}", templatePath)); Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); builder.InsertHtml(html); doc.Save(newFilePath, Aspose.Words.SaveFormat.Doc); }
html转成pdf
/// <summary> /// html转pdf /// </summary> /// <param name="path"></param> /// <param name="newFilePath">加密采用的编码方式</param> /// <returns></returns> public static void HtmlToPdf(string path, string newFilePath) { var dir = newFilePath.Substring(0, newFilePath.LastIndexOf("/") + 1); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Aspose.Words.Document doc = new Aspose.Words.Document(path); doc.Save(newFilePath); }
相关推荐
beibeijia 2019-10-30
gougouzhang 2019-06-26
lizhiyong 2019-06-21
lxhuang 2018-12-22
帅的相对论 2013-04-17