Spire.Doc 11.8.11 已发布。本次更新新增支持转换数学公式到 OfficeMathMLCode 以及邮件合并时为图片添加超链接,同时还增强了 Word 到 PDF 和 HTML 以及 HTML 到 Word 的转换功能。此外,许多已知问题也在该版本中得到修复,如添加页码域之后不能自动更新域的问题。详情请阅读以下内容。
新功能:
- 支持转换数学公式到OfficeMathMLCode。
- 支持邮件合并时为图片添加超链接。
Document doc = new Document();
doc.LoadFromFile("1.docx");
StringBuilder stringBuilder = new StringBuilder();
foreach (Section section in doc.Sections)
{
foreach (Paragraph par in section.Body.Paragraphs)
{
foreach (DocumentObject obj in par.ChildObjects)
{
OfficeMath omath = obj as OfficeMath;
if (omath == null) continue;
string mathml = omath.ToOfficeMathMLCode();
stringBuilder.Append(mathml);
stringBuilder.Append("\r\n");
}
}
}
File.WriteAllText("1.txt", stringBuilder.ToString());
doc.Close();
Document doc = new Document();
doc.LoadFromFile("Test.docx");
var fieldNames = new string[] { "MyImage" };
var fieldValues = new string[] { "logo.png" };
doc.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);
doc.MailMerge.Execute(fieldNames, fieldValues);
doc.SaveToFile("result.docx", FileFormat.Docx);
}
void MailMerge_MergeImageField(object sender, MergeImageFieldEventArgs field)
{
string filePath = field.FieldValue as string;
if (!string.IsNullOrEmpty(filePath))
{
field.Image = Image.FromFile(filePath);
field.ImageLink = "https://www.e-iceblue.com/";
}
}
问题修复:
- 修复了加载Word文档时报错程序抛System.InvalidOperationException异常的问题。
- 修复了转换Word到PDF时分页不一致的问题。
- 修复了转换Word到PDF时报错程序抛System.NullReferenceException异常的问题。
- 修复了将从语雀导出的Docx文件转换成HTML文件失败的问题。
- 修复了添加页码域之后不能自动更新域的问题。
- 修复了转换HTML到Doc时后列表字符显示不正确的问题。
- 修复了转换HTML到Doc时换行标签无效的问题。
- 修复了转换Docx到PDF时logo丢失的问题。
- 修复了加载RTF文档报错程序抛System.NullReferenceException异常的问题。
- 修复了Latex公式中符号“~”解析不正确的问题。
- 修复了转换Word到PDF时TOC在多个页面上被分割的问题。
- 修复了转换Docx到HTML时图片不清晰的问题。
- 修复了转换Word到PDF时多出文本的问题。
- 修复了加载文档另存为新文档后内容不一致的问题。
- 修复了添加HTML字符串时程序悬挂的问题。
获取Spire.Doc 11.8.11请点击: