Spire.Office 10.8.0 更新已发布。在该版本中,Spire.Doc 支持比较两个列表级别是否一致;Spire.Presentation 加强了PPTX 转 PDF;Spire.PDF 支持转换 PDF 到 SVG 时设置 SVG 文件的宽高。此外,大量已知问题在该版本中成功修复。详情请阅读以下内容。
该版本涵盖了最新版的 Spire.Doc、Spire.PDF、Spire.XLS、Spire.Presentation、Spire.Barcode、Spire.Email、Spire.DocViewer、Spire.PDFViewer、Spire.OfficeViewer 和 Spire.DataExport。
版本信息如下:
- Spire.Doc.dll v13.8.1
- Spire.PDF.dll v11.8.7
- Spire.XLS.dll v15.8.3
- Spire.Presentation.dll v10.8.2
- 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.8
- Spire.PDFViewer.Forms.dll v8.1.8
- 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.8.0,请点击:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.Doc
新功能:
- 新增“ListLevel.Equals(ListLevel level)”比较两个列表级别是否一致。
- 支持设置或删除图片项目符号。
// 创建 Document 对象
Document document = new Document();
// 创建列表样式
ListStyle listStyle_1 = document.Styles.Add(ListType.Bulleted, "bulletList");
ListLevelCollection Levels_1 = listStyle_1.ListRef.Levels;
ListLevel L0 = Levels_1[0];
ListLevel L1 = Levels_1[1];
ListLevel L2 = Levels_1[2];
ListStyle listStyle_2 = document.Styles.Add(ListType.Bulleted, "bulletList");
ListLevelCollection Levels_2 = listStyle_2.ListRef.Levels;
ListLevel l0 = Levels_2[0];
ListLevel l1 = Levels_2[1];
ListLevel l2 = Levels_2[2];
// 设置列表样式
L0.ParagraphFormat.LineSpacing = 10 * 1.5f;
L1.CharacterFormat.FontSize = 9;
L1.IsLegalStyleNumbering = true;
L1.PatternType = ListPatternType.Arabic;
L1.FollowCharacter = FollowCharacterType.Nothing;
L1.BulletCharacter = "\x006e";
L1.NumberAlignment = ListNumberAlignment.Left;
L1.NumberPosition = -10;
L1.TabSpaceAfter = 0.5f;
L1.TextPosition = 0.5f;
L1.StartAt = 4;
L1.NumberSufix = "章";
L1.NumberPrefix = "第";
L1.NoRestartByHigher = false;
L1.UsePrevLevelPattern = false;
L2.CharacterFormat.FontName = "黑体";
// 创建列表样式2
l0.ParagraphFormat.LineSpacing = 10 * 1.5f;
l1.CharacterFormat.FontSize = 9;
l1.IsLegalStyleNumbering = true;
l1.PatternType = ListPatternType.Arabic;
l1.FollowCharacter = FollowCharacterType.Nothing;
l1.BulletCharacter = "\x006e";
l1.NumberAlignment = ListNumberAlignment.Left;
l1.NumberPosition = -10;
l1.TabSpaceAfter = 0.5f;
l1.TextPosition = 0.5f;
l1.StartAt = 4;
l1.NumberSufix = "章节";
l1.NumberPrefix = "第";
l1.NoRestartByHigher = false;
l1.UsePrevLevelPattern = false;
l1.CreatePictureBullet();
l2.CharacterFormat.FontName = "黑体";
// 比较两个列表级别是否一致
bool r0 = L0.Equals(l0);
bool r1 = L1.Equals(l1);
bool r2 = L2.Equals(l2);
// 创建 Document 对象
Document document = new Document();
// 添加一节
Section sec = document.AddSection();
Spire.Doc.Documents.Paragraph paragraph = sec.AddParagraph();
// 创建列表样式
ListStyle listStyle = document.Styles.Add(ListType.Bulleted, "bulletList");
ListLevelCollection Levels = listStyle.ListRef.Levels;
Levels[0].CreatePictureBullet();
Levels[0].PictureBullet.LoadImage(@"logo.jpg");
Levels[1].CreatePictureBullet();
Levels[1].PictureBullet.LoadImage(@"py.jpg");
// 添加段落并应用段落样式
paragraph = sec.AddParagraph();
paragraph.AppendText("项目 1");
paragraph.ListFormat.ApplyStyle(listStyle);
paragraph = sec.AddParagraph();
paragraph.AppendText("项目 1.1");
paragraph.ListFormat.ApplyStyle(listStyle);
paragraph.ListFormat.ListLevelNumber = 1;
// 删除图片项目符号
Levels[0].DeletePictureBullet();
// 保存文件
document.SaveToFile(@"out.docx", FileFormat.Docx);
document.Close();
调整:
- 弃用“Document.ListStyles”属性,替换为“Document.ListReferences”。并在“Document.ListReferences”中新加方法创建“ListDefinitionReference”类。
- 回收“ListStyle”的对外公开的构造方法,“ListStyle”对象存放于“Document.Styles”集合中,使用“StyleCollection.Add(ListType listType, string name)”方法添加。
- 段落应用列表样式方式改为“ListFormat.ApplyStyle(ListStyle listStyle)”或“ListFormat.ApplyListRef(ListDefinitionReference list, int leverNumber)”。
- 属性“ListFormat.CurrentListStyle”变更为“ListFormat.CurrentListRef”。
- 回收弃用“ListFormat.IsRestartNumbering”和 “ListFormat.CustomStyleName”。
- 回收弃用“ListFormat.IsRestartNumbering”和 “ListFormat.CustomStyleName”。
// 创建 Document 对象
Document document = new Document();
// 添加一节
Section sec = document.AddSection();
Spire.Doc.Documents.Paragraph paragraph = sec.AddParagraph();
// 创建列表模板1
ListTemplate template = ListTemplate.BulletDefault;
ListDefinitionReference listRef = document.ListReferences.Add(template);
// 创建列表模板2
ListTemplate template1 = ListTemplate.NumberDefault;
ListDefinitionReference listRef1 = document.ListReferences.Add(template1);
listRef1.Levels[2].StartAt = 4;
int levelcount = listRef.Levels.Count;
// 添加段落并应用样式
paragraph = sec.AddParagraph();
paragraph.AppendText("项目 1");
paragraph.ListFormat.ApplyListRef(listRef, 1);
paragraph = sec.AddParagraph();
paragraph.AppendText("项目 2");
paragraph.ListFormat.ApplyListRef(listRef, 2);
paragraph = sec.AddParagraph();
paragraph.AppendText("项目3");
paragraph.ListFormat.ApplyListRef(listRef1, 1);
paragraph = sec.AddParagraph();
paragraph.AppendText("项目 4");
paragraph.ListFormat.ApplyListRef(listRef1, 2);
// 保存文件
document.SaveToFile("out.docx", FileFormat.Docx);
document.Close();
ListStyle listStyle = document.Styles.Add(ListType.Numbered, "levelstyle");
listStyle.IsCustomStyle = true;
listStyle.CharacterFormat.FontName = "Trebuchet MS";
ListLevelCollection levels = listStyle.ListRef.Levels;
levels[0].PatternType = ListPatternType.Arabic;
levels[0].StartAt = 1;
levels[0].CharacterFormat.FontName = "Trebuchet MS";
ListStyle numberList2 = document.Styles.Add(ListType.Numbered, "Numbered2");
ListLevelCollection Levels = numberList2.ListRef.Levels;
Levels[0].StartAt = 10;
Spire.Presentation
更新依赖项:
- .NET Core 2.0
- .NET 6.0
Microsoft.Win32.Registry >= 4.5.0
System.Drawing.Common >= 4.7.2
System.Security.Permissions >= 4.7.0
System.Text.Encoding.CodePages >= 4.5.0
System.Security.Cryptography.Pkcs >= 4.7.0
System.Security.Cryptography.Xml >=4.7.1
HarfBuzzSharp >=8.3.0.1
Microsoft.Win32.Registry >= 5.0.0
System.Drawing.Common >= 6.0.0
System.Security.Permissions >= 6.0.0
System.Text.Encoding.CodePages >= 6.0.0
System.Security.Cryptography.Pkcs >= 6.0.5
System.Security.Cryptography.Xml >= 6.0.2
HarfBuzzSharp >=8.3.0.1
问题修复:
- 修复了转换 PPTX 到 PDF ,设置默认替代字体效果不正确的问题。
- 修复了转换 PPTX 到 PDF ,背景色不正确的问题。
- 修复了转换 PPTX 到 PDF ,文本字号变小的问题。
- 修复了转换 PPTX 到 PDF ,文本格式不正确的问题。
- 修复了转换 PPTX 到 PDF ,形状格式不正确的问题。
- 修复了转换 PPTX 到 PDF ,形状颜色不正确的问题。
- 修复了转换 PPTX 到 PDF ,多出方框的问题。
Spire.PDF
新功能:
- 支持转换PDF到SVG时设置SVG文件的宽高。
PdfToSvgConverter converter = new PdfToSvgConverter(inputFile);
converter.SvgOptions.ScaleX = (float)0.5;
converter.SvgOptions.ScaleY = (float)0.5;
converter.Convert(outputFile);
优化:
- 优化了转换 PDF 到 PDFA 的耗时。
调整:
- 升级了 .NET Core 2.0 和 .NET 6.0 中部分依赖的版本。
问题修复:
- 修复了转换 PDF 到 Tiff 图片,内容存在差异的问题。
- 修复了转换 PDF 到 PPTX,文本变图片的问题。
- 修复了转换 PDF 到 Tiff 图片,内容模糊且文本变黑块的问题。
- 修复了表格单元格跨页时遇到换行符导致下一页剩余文本不显示的问题。
- 修复了提取 PDF 文档中的文本,程序抛 “illegal Subtype 'Type2' in font dictionary.” 异常的问题。
- 修复了自定义 DPI 转换图片时尺寸不正确的问题。
- 修复了替换文本时,程序抛 “未将对象引用设置到对象的实例” 的问题。
- 修复了将 EMF 图像添加到 PDF 时,部分文字方向被错误反转的问题。
- 修复了将 PDF 转换为 SVG 格式时,LinearGradient和RadialGradient 渐变效果不被支持的问题。
- 修复了在 PDF 中替换文本时,字体样式不正确的问题。
- 修复了在容器环境中使用 QT 进行 HTML 到 PDF 转换时,无法生成输出文件的问题。
- 修复了由 PDF 转换生成的 HTML 文件无法在“jodit-react WYSIWYG”编辑器中正常编辑的问题。
- 修复了向 PDF 图层(Layer)并发添加文本时,程序抛出 InvalidOperationException 异常的问题。
- 修复了将 PDF 转换为图片时,输出图片质量模糊的问题。
- 修复了将 OFD 文件转换为 PDF时,文本字体被更改的问题。