Spire.Office 9.4.0 已发布。在该版本中,Spire.Doc 支持加载和操作 Markdown 文档;Spire.PDF 支持获取查找到的文本的字体、字体大小以及字体格式;Spire.Presentation 支持在段落中插入公式以及将 SVG 文件以图片形式嵌入到幻灯片中。此外,大量已知问题也在该版本中成功修复。详情请阅读以下内容。
该版本涵盖了最新版的 Spire.Doc,Spire.PDF,Spire.XLS,Spire.Email,Spire.DocViewer,Spire.PDFViewer,Spire.Presentation,Spire.Spreadsheet,Spire.OfficeViewer,Spire.Barcode,Spire.DataExport。
版本信息如下:
- Spire.Doc.dll v12.4.7.0
- Spire.Pdf.dll v10.4.7.0
- Spire.XLS.dll v14.4.7.0
- Spire.Presentation.dll v9.4.5.0
- Spire.Barcode.dll v7.2.9.0
- Spire.Email.dll v6.5.10.0
- Spire.DocViewer.Forms.dll v8.7.8.0
- Spire.PdfViewer.Asp.dll v7.12.14.0
- Spire.PdfViewer.Forms.dll v7.12.14.0
- Spire.Spreadsheet.dll v7.4.6.0
- Spire.OfficeViewer.Forms.dll v8.7.10.0
- Spire.DataExport.dll v4.9.0.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 支持了加载操作 MarkDown 文档,或转换 Word 格式文档到 MarkDown。
Document doc = new Document();
//加载 .md 文件
doc.LoadFromFile("input.md");
//保存为 .md 文件
//doc.SaveToFile("output.md", Spire.Doc.FileFormat.Markdown);
//保存为 .docx 文件
//doc.SaveToFile("output.docx", Spire.Doc.FileFormat.Docx);
//保存为 .doc 文件
//doc.SaveToFile("output.doc", Spire.Doc.FileFormat.Doc);
//保存为 .pdf 文件
doc.SaveToFile("output.pdf", Spire.Doc.FileFormat.PDF);
doc.Close();
Document doc = new Document();
//加载 .docx 文件
doc.LoadFromFile("input.docx");
//加载 .doc 文件
//doc.LoadFromFile("input.doc");
//保存为 .md 文件
doc.SaveToFile("output.md", Spire.Doc.FileFormat.Markdown);
doc.Close();
问题修复:
- 修复了设置 Header.LinkToPrevious 和 Footer.LinkToPrevious 不生效的问题。
- 修复了 Word 转 PDF,部分内容丢失的问题。
- 修复了 Word 转 PDF,书签不正确的问题。
- 修复了 ReplaceInLine 方法抛 “System.NullReferenceException” 的问题。
Spire.PDF
新功能:
- 支持获取查找到的文本的字体及字体大小。
- 支持获取查找到的文本的字体格式。
注意:仅支持获取加粗、模拟加粗(字体样式设置填充加描边)、斜体、颜色,不支持获取下划线。 - 新增了保存文档时的进度回调接口。
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("test.pdf");
PdfTextFindOptions findOptions = new PdfTextFindOptions();
findOptions.Parameter = TextFindParameter.IgnoreCase;
foreach (PdfPageBase page in pdf.Pages)
{
PdfTextFinder finder = new PdfTextFinder(page);
finder.Options = findOptions;
List results = finder.Find("total");
foreach (PdfTextFragment text in results)
{
String font=text.TextStates[0].FontName;
float size = text.TextStates[0].FontSize;
String fontF = text.TextStates[0].FontFamily;
}
}
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
PdfPageBase page = pdf.Pages[0];
PdfTextFinder finds = new PdfTextFinder(page);
finds.Options.Parameter = TextFindParameter.None;
List<PdfTextFragment> result = finds.Find("hello");
StringBuilder str = new StringBuilder();
foreach (PdfTextFragment find in result)
{
string text = find.LineText;
string FontName = find.TextStates[0].FontName;
float FontSize = find.TextStates[0].FontSize;
string FontFamily = find.TextStates[0].FontFamily;
bool IsBold = find.TextStates[0].IsBold;
bool IsSimulateBold = find.TextStates[0].IsSimulateBold;
bool IsItalic = find.TextStates[0].IsItalic;
Color color = find.TextStates[0].ForegroundColor;
str.AppendLine(text);
str.AppendLine("FontName: " + FontName);
str.AppendLine("FontSize: " + FontSize);
str.AppendLine("FontFamily: " + FontFamily);
str.AppendLine("IsBold: " + IsBold);
str.AppendLine("IsSimulateBold: " + IsSimulateBold);
str.AppendLine("IsItalic: " + IsItalic);
str.AppendLine("color: " + color);
str.AppendLine(" ");
}
PdfTextReplacer ptr = new PdfTextReplacer(page);
ptr.ReplaceAllText("hello", "New");
File.WriteAllText(outputFile_T, str.ToString());
pdf.SaveToFile(outputFile);
pdf.Dispose();
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
pdf.RegisterProgressNotifier(new CustomProgressNotifier());
pdf.SaveToFile(outputFile, FileFormat.XPS);
pdf.Close();
public class CustomProgressNotifier :IProgressNotifier
{
StringBuilder str = new StringBuilder();
public void Notify(float progress)
{
str.AppendLine(progress + "%");
File.WriteAllText(outputFile_txt, str.ToString());
}
}
问题修复:
- 优化了构建多页数 PDF 耗时长的问题。
- 优化了 PdfDestination 方法的效果。
- 修复了设置 PDF 表单域扁平化后,内容丢失的问题。
- 优化了压缩 PDF 的耗时。
- 修复了查找高亮不生效的问题。
- 修复了转灰度 PDF,程序抛 “OutOfMemoryException” 异常的问题。
- 修复了 XPS 转 PDF,部分字符显示不正确的问题。
- 修复了 OFD 转 PDF,程序抛 “FormatException” 异常的问题。
- 修复了 XPS 转 PDF,图片丢失的问题。
- 优化了压缩 PDF 效果。
- 修复了 PDF 转图片,程序抛 “ArgumentOutOfRangeException” 的问题。
- 修复了不能对垂直对齐格式的文本进行高亮的问题。
- 修复了使用 PdfDocument.LoadFromFile(string filename) 方法加载有密码的文档时程序没有报错的问题。
- 修复了用 Adobe 工具打开从XPS文档转换出的 PDF 文档时弹出提示字体有问题的对话框。
- 修复了转换 PDF 文档到 OFD 文档时不可见的透明的文本被显示出来的问题。
- 修复了转换 OFD 文档到 PDF 文档时程序抛出异常 System.ArgumentException 的问题。
- 修复了转换 PDF 文档到图片时内容丢失的问题。
- 修复了绘制含有 "∙" (unicode = 8729) 字符的文本到 PDF 页面失败的问题。
- 修复了打印转灰度后的 PDF 时程序抛出 System.NullReferenceException 异常的问题。
- 修复了转换灰度 PDF 文档时程序抛出 System.ArgumentNullException 异常的问题。
- 修复了用 signatureOne.VerifySignature() 验证数字签名结果不正确的问题。
- 修复了转换 XPS 文档到 PDF 文档时图片丢失的问题。
- 修复了转换 OFD 文档到 PDF 文档时程序抛出 System.NullReferenceException 异常的问题。
- 修复了加载和保存 PDF 文档后签名无效的问题。
- 修复了转换 OFD 文档到 PDF 文档时程序抛出 System.ArgumentException 异常的问题。
- 修复了查找文本时程序抛出 System.ArgumentNullException 异常的问题。
Spire.Presentation
新功能:
- 支持添加占位符。
- 支持设置地图图表的地图投影功能。
- 支持在段落中插入公式。
- 支持将 SVG 文件以图片形式嵌入到幻灯片中。(仅 PPTX2016 及以上版本支持此功能,PPT 格式的文档不支持)
public enum InsertPlaceholderType
{
Content = 0,
VerticalContent = 1,
Text = 2,
VerticalText = 3,
Picture = 4,
Chart = 5,
Table = 6,
SmartArt = 7,
Media = 8,
OnlineImage = 9
}
presentation.Masters[0].Layouts[0].InsertPlaceholder(InsertPlaceholderType.Text, new RectangleF(20, 30, 400, 400));
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
IChart chart = ppt.Slides[0].Shapes[9] as IChart;
ProjectionType type = chart.Series[0].ProjectionType;
chart.Series[0].ProjectionType = ProjectionType.Robinson;
ppt.SaveToFile(outputFile, FileFormat.Pptx2013);
ppt.Dispose();
Presentation ppt = new Presentation();
string latexMathCode = "x^{2}+\\sqrt{x^{2}+1=2}";
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(30, 100, 400, 200));
shape.TextFrame.Paragraphs.Clear();
TextParagraph p = new TextParagraph();
p.ParagraphProperties.DefaultTextRangeProperties.Fill.FillType = FillFormatType.Solid;
p.ParagraphProperties.DefaultTextRangeProperties.Fill.SolidColor.Color = Color.Black;
shape.TextFrame.Paragraphs.Append(p);
TextRange portionEx = new TextRange("Hello World");
p.TextRanges.Append(portionEx);
p.AppendFromLatexMathCode(latexMathCode);
TextRange portionEx2 = new TextRange("My name is Tom.");
p.TextRanges.Append(portionEx2);
ppt.SaveToFile(outputFile, FileFormat.Auto);
ppt.Dispose();
presentation.Slides[0].Shapes.AddFromSVG(inputFile, new RectangleF(40, 40, 200, 200));
问题修复:
- 修复了转换 PPTX 文档到 SVG 文档时形状渐变色背景的方向被旋转的问题
Spire.XLS
问题修复:
- 修复了转换 Excel 文档到图片时透视表数据不正确的问题。
- 修复了转换 Excel 文档到 PDF 文档时程序抛出 System.NullReferenceException 异常的问题。
- 修复了加载 Excel 文档时程序抛出 System.NullPointerException 异常的问题。
- 修复了加载 Excel 文档时程序抛出 System.NullReferenceException 异常的问题。
- 修复了用 Spire.Xls 读取一个 xltm 文档并保存到一个新的xltm文档后用 MS Excel 工具打开这个文档失败的问题。
- 修复了使用 Worksheet.InsertDataTable() 方法插入包含公式的数据时公式没有被做计算的问题。