我正在做个html文件转word格式下载的问题,现在出现的问题,html的图片转成word后,如果不联网,不能显示,应该是word文件里存储的还是图片的链接地址,而没有改变为word的存储方式,请问这个问题该怎样解决?
解决方案 »
- asp.net c# oracle 删除数据问题(delete)
- 高手请入!如何得到TreeView排序后的数据
- 模拟post登录求解
- 我的asp.net网站为什么不能用asp文件啊
- 父页面弹出子页面的同时,为什么父页面的一个TextBox的值却不能正常显示显示出来?
- 如何给table添加双击事件(C#)
- 请问为什么服务器上的 Tree 不能显示
- 怎样不在程序中引用DLL,又能使用此DLL中的代码方法?
- 急急急,请教asp.net(UI)高手,关于datagrid外观的问题!
- 如何计算100000的阶乘,要求结果为精确值?如32330999,得到为3.233099*10 的n次方,又如何?
- js传值
- 收藏 MVC3 RedirectToAction跳转页面问题
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Words;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Text;public partial class Bom2_exportWord : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string html = Request.Form["content"].ToString();
string filename = Request.Form["filename"].ToString();
string hostpath = Request.Url.AbsoluteUri.ToString().Substring(0, Request.Url.AbsoluteUri.ToString().Length - Request.Url.LocalPath.ToString().Length+1);
Regex rx = new Regex(@"(?<=src="")(.*?)(?="")", RegexOptions.IgnoreCase | RegexOptions.Singleline);
html = rx.Replace(html, hostpath + "$1");
rx = new Regex(@"(?<=href="")(.*?)(?="")", RegexOptions.IgnoreCase | RegexOptions.Singleline);
html = rx.Replace(html, hostpath + "$1"); //TextBox1.Text = html;
//return;
Document doc = new Document();
doc.ViewOptions.ViewType = Aspose.Words.ViewType.Web;
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(html);
foreach (Aspose.Words.Section section in doc)
{
section.PageSetup.TopMargin = 20;
section.PageSetup.BottomMargin = 20;
section.PageSetup.LeftMargin = 20;
section.PageSetup.RightMargin = 20;
}
Response.Clear();
Request.Url.Host.ToString();
doc.Save(filename, SaveFormat.Doc, SaveType.OpenInWord, Response);
}
}