Spire.Office 10.7.0 更新已发布。在该版本中,Spire.Doc 新增支持多项新功能,如加载 EPUB 文件进行处理和创建组合图表;Spire.PDF 支持提取 PDF 自定义数据,同时增强了 PDF 到 Excel 的转换效果;Spire.XLS 和 Spire.Presentation 支持加载 Markdown 格式文档。此外,大量已知问题在该版本中成功修复。详情请阅读以下内容。
该版本涵盖了最新版的Spire.Doc、Spire.PDF、Spire.XLS、Spire.Presentation、Spire.DataExport、Spire.Barcode、Spire.DocViewer、Spire.PDFViewer、Spire.OfficeViewer、Spire.Email。
版本信息如下:
- Spire.Doc.dll v13.7.14
- Spire.Pdf.dll v11.7.14
- Spire.XLS.dll v15.7.8
- Spire.Presentation.dll v10.7.7
- Spire.Barcode.dll v7.3.7
- Spire.Email.dll v6.6.3
- Spire.DocViewer.Forms.dll v8.9.1
- Spire.PdfViewer.Asp.dll v8.1.3
- Spire.PdfViewer.Forms.dll v8.1.3
- Spire.Spreadsheet.dll v7.5.2
- Spire.OfficeViewer.Forms.dll v8.8.0
- Spire.DataExport.dll 4.9.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
获取Spire.Office 10.7.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 支持加载epub文件进行处理
- 支持Word 转Pdf_UA1格式。
- 新增配置参数增强了Word转Markdown 的性能效果,如设置表格文本对齐方式,列表导出方式等。
- 支持创建组合图表。
- 新增‘setDefaultSubstitutionFontName’方法,支持设置默认的替换字体。
- 新增‘StructureDocumentTag.RemoveSelfOnly()’方法,支持移除SDT保留内容。
- 支持Word转PDF时设置图片压缩方式。
- 支持从OMML添加公式到Word文档。
- 支持Math公式转到Latex。
Document doc = new Document();
doc.LoadFromFile("in.epub", Spire.Doc.FileFormat.EPub);
doc.SaveToFile(@"out.docx", Spire.Doc.FileFormat.Docx);
doc.SaveToFile(@"out.pdf", Spire.Doc.FileFormat.PDF);
Document doc = new Document();
doc.LoadFromFile("in.docx");
ToPdfParameterList list = new ToPdfParameterList();
list.PdfConformanceLevel = PdfConformanceLevel.Pdf_UA1;
doc.SaveToFile(@"out.pdf", list);
Document doc = new Document();
Paragraph paragraph = doc.AddSection().AddParagraph();
Chart chart = paragraph.AppendChart(ChartType.Column, 450, 300).Chart;
//Modify 'Series 3' to a line chart and display it on the secondary axis
chart.ChangeSeriesType("Series 3", ChartSeriesType.Line, true);
Console.WriteLine(chart.Series[2].ChartType);
doc.SaveToFile("ComboChart.docx");
Document document = new Document();
//Set default replacement font
doc.DefaultSubstitutionFontName = "Arial";
Section sec = doc.AddSection();
Paragraph para = sec.AddParagraph();
TextRange tr = para.AppendText("test");
//The system does not have this font
tr.CharacterFormat.FontName = "Helvetica";
doc.SaveToFile(outputFile, FileFormat.PDF);
// Process inline structure tags
List tagInlines = structureTags.getM_tagInlines();
for (int i = 0; i < tagInlines.Count; i++)
{
tagInlines[i].RemoveSelfOnly();
}
// Process other structure tags
List tags = structureTags.getM_tags();
for (int i = 0; i < tags.Count; i++)
{
tags[i].RemoveSelfOnly();
}
// Process StructureDocumentTagRow
List rowtags = structureTags.getM_rowtags();
for (int i = 0; i < rowtags.Count; i++)
{
rowtags[i].RemoveSelfOnly();
}
// Process StructureDocumentTagCell
List celltags = structureTags.getM_celltags();
for (int i = 0; i < celltags.Count; i++)
{
celltags[i].RemoveSelfOnly();
Document document = new Document();
document.LoadFromFile(@"Sample.docx");
ToPdfParameterList para = new ToPdfParameterList();
para.PdfImageCompression = Spire.Doc.Export.PdfImageCompression.Jpeg;
document.SaveToFile(outputFile,para);
Document document = new Document();
Section section = doc.AddSection();
foreach (string ommlCode in OmmlCodes)
{
OfficeMath officeMath = new OfficeMath(doc);
officeMath.CharacterFormat.FontSize = 14f;
officeMath.FromOMMLCode(ommlCode);
section.AddParagraph().ChildObjects.Add(officeMath);
}
doc.SaveToFile(outputFile, FileFormat.Docx2013);
doc.Dispose();
Document document = new Document();
doc.LoadFromFile(inputFile);
StringBuilder stringBuilder = new StringBuilder();
// Iterate through sections in the document
foreach (Section section in doc.Sections)
{
// Iterate through paragraphs in each section
foreach (Paragraph par in section.Body.Paragraphs)
{
// Iterate through child objects in each paragraph
foreach (DocumentObject obj in par.ChildObjects)
{
// Check if the object is an OfficeMath equation
OfficeMath omath = obj as OfficeMath;
if (omath == null) continue;
// Convert OfficeMath equation to LaTex code
string mathml = omath.ToLaTexMathCode();
// Append MathML code to the StringBuilder
stringBuilder.Append("LaTeX code" + mathml);
stringBuilder.Append("\r\n");
}
}
}
// Write the LaTex code to a text file
File.WriteAllText(outputFile, stringBuilder.ToString())
问题修复:
- 修复了 Doc 转 PDF 时,页眉的图片被拉伸的问题。
Spire.PDF
新功能:
- 新增 GetCustomApplicationData() 支持提取 PDF 自定义数据值。
- 支持在 XlsxLineLayoutOptions.TextRecognizer 中集成 PaddleOCRSharp,以增强 PDF 到 Excel 的转换效果。
PdfDocument doc = new PdfDocument(inputFile);
PdfApplicationData appplicationDataObject = doc.GetCustomApplicationData();
Dictionary
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("in.pdf");
XlsxLineLayoutOptions options = new XlsxLineLayoutOptions(false, false, false, true);
options.TextRecognizer = new TextRecognizer();
doc.ConvertOptions.SetPdfToXlsxOptions(options);
doc.SaveToFile("out.xlsx", Spire.Pdf.FileFormat.XLSX);
// niget install PaddleOCRSharp lib
using PaddleOCRSharp;
using Spire.Pdf.Conversion;
public class TextRecognizer : ITextRecognizer
{
private static readonly PaddleOCREngine _engine;
static TextRecognizer()
{ _engine = new PaddleOCREngine(null, “”); }
public string RecognizeGlyph(Stream glyphImageStream)
{
var image = new System.Drawing.Bitmap(glyphImageStream);
// paint glyph in image center
var fixImage = new System.Drawing.Bitmap(160, 240);
using (Graphics g = Graphics.FromImage(fixImage))
{ g.DrawImage(image, new RectangleF(20, 20, fixImage.Width - 40, fixImage.Height - 40), new RectangleF(0, 0, image.Width, image.Height), GraphicsUnit.Pixel); }
var unicodeResult = _engine.DetectText(fixImage).Text;
return unicodeResult;
}
}
问题修复:
- 优化了转换 PDF 到图片的耗时。
- 修复了 PDF 转 PDF/A-1A 时,泰文文本显示不正确的问题。
- 修复了高亮 PDF 文本时,透明度效果不正确的问题。
- 修复了绘制图片到 PDF 页面时效果不正确的问题。
- 修复了 PDF 表单域 Flatten 效果不正确的问题。
- 修复了压缩 PDF 时程序抛出 “ArgumentException” 的问题。
- 修复了 PDF 转 TIFF 时程序抛出 “NullReferenceException” 的问题。
- 修复了打印 PDF 内容出现阴影的问题。
- 修复了 OFD 转 PDF 后,Adobe 打开结果文档报错的问题。
- 修复了定义字体时程序抛出 “InvalidOperationException” 的问题。
- 修复了 PDF 转图片时程序抛出 “NullReferenceException” 的问题。
- 修复了在 netstandard DLL 中取消打印操作时程序抛出 “System.Exception” 的问题。
- 修复了合并 PDF 文件时程序抛出 “Value cannot be null” 的问题。
- 修复了EMF转PDF时,阿拉伯语文本显示效果不正确的问题。
- 修复了 XPS 转 PDF 内容不正确的问题。
- 优化了 PDF 转图片的耗时性能。
- 优化了打印 PDF 耗时性能。
- 修复了 PDF 转图片,内容丢失的问题。
- 修复了提取 PDF 内容失败的问题。
- 修复了 PDF 转图片,内容被覆盖的问题。
- 修复了 OFD 转 PDF 或图片,内容不正确的问题。
- 修复了 Attachments.Add() 添加附件导致多个 ” Indirect reference“ 引用的问题。
- 修复了 PDF 转 PDFA,内容不正确的问题。
- 修复了释放 pdfTextFinder 对象抛 "System.NullReferenceException" 异常的问题。
Spire.XLS
新功能:
- 支持了 LoadFromMarkdown() 方法加载 Markdown 格式文档。
Workbook wb = new Workbook();
wb.LoadFromMarkdown("test.md");
wb.SaveToFile("out.pdf", FileFormat.PDF);
wb.SaveToFile("out.xlsx", ExcelVersion.Version2010);
问题修复:
- 修复了 Excel 转 PDF,复选框显示不正确的问题。
- 修复了 AGGREGATE 公式计算不正确的问题。
- 修复了 Excel 转 PDF 时内容重叠的问题。
- 修复了 Excel 转 PDF 时文本换行不正确的问题。
- 修复了取消分组(Ungroup)效果不正确的问题。
- 修复了 Excel 转 PDF 时分页位置不一致的问题。
- 修复了公式计算结果为 "#VALUE!" 的问题。
Spire.Presentation
新功能:
- 支持加载 Markdown 格式文件。
Presentation pt = new Presentation();
pt.LoadFromFile(inputFilePath, FileFormat.Markdown);
pt.SaveToFile(outputFile, FileFormat.Pptx2013);
问题修复:
- 修复了带有复制幻灯片的文件打开报错的问题。