Aspose.Words.DocumentBuilder的InsertHtml() :将html文本字符转word报错,索引超出数组界限
使用InsertHtml()将html文本字符串,转为word时,报索引超出数组界限
请问一下,有谁知道这个方法支持的最大长度是多?
方式一:
aspose.words.document doc=new aspose.words.document();
aspose.words.documentbuilder builder=new aspose.words.documentbuilder(doc);
builder.inserthtml(str);
方式二:
var bytes=system.text.encoding.utf8.getbytes(str);
aspose.words.document doc=new aspose.words.document(new memorystream(bytes));
字符串str的字节数大概是24万,两种方式都报“索引超出数组界限”
邮件发你了,在附件中,下载下来用编辑器打开复制里面的内容
方式一:
aspose.words.document doc=new aspose.words.document();
aspose.words.documentbuilder builder=new aspose.words.documentbuilder(doc);
builder.inserthtml(str);
方式二:
var bytes=system.text.encoding.utf8.getbytes(str);
aspose.words.document doc=new aspose.words.document(new memorystream(bytes));
字符串str的字节数大概是24万,两种方式都报“索引超出数组界限”
str使用的是html源码,请查看附件
(Attachment 如何将整个网站离线储存到本地? - 知乎.html is missing)
@jason11 我已经使用以下代码检查了您的 HTML:
Document doc = new Document(@"C:\Temp\in.html");
doc.Save(@"C:\Temp\out.docx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(@"C:\Temp\in.html"));
doc.Save(@"C:\Temp\out.docx");
这两种方法对我来说都很好。 您能否提供一个代码示例,使我们能够重现该问题? 我们将检查问题并为您提供更多信息。
你直接将html里面的源码,copy替换到str中
aspose.words.document doc=new aspose.words.document();
aspose.words.documentbuilder builder=new aspose.words.documentbuilder(doc);
builder.inserthtml(str);
其实就是将html源码作为字符串,传入builder.inserthtml(str);这个方法中,
不是以html文件的形式读取。
稍晚点,公司电脑没环境。我晚点做个列子上传上来
感谢!!!
我回去试试最新版的看看啥效果