Spire.Office 8.11.0 已发布。在该版本中,Spire.PDF 新增支持按阅读顺序获取分栏文档的文本坐标;Spire.Doc 新增转换 Word 到 PDF 时文本整形的功能;Spire.XLS 新增支持自定义透视表字段的名称;Spire.Presentation 新增支持获取形状内文本的位置信息的功能。此外,许多已知问题也在该版本中成功修复。详情请阅读以下内容。
该版本涵盖了最新版的 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 v11.10.11
- Spire.Pdf.dll v9.10.2
- Spire.XLS.dll v13.10.3
- Spire.Presentation.dll v8.10.3
- Spire.Email.dll v6.5.8
- Spire.DocViewer.Forms.dll v8.7.3
- Spire.PdfViewer.Forms.dll v7.12.1
- Spire.PdfViewer.Asp.dll v7.12.1
- Spire.Spreadsheet.dll v7.4.3
- Spire.OfficeViewer.Forms.dll v8.10.2
- Spire.Barcode.dll v7.2.3
- Spire.DataExport.dll v4.9.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
Spire.PDF
新功能:
- 支持按阅读顺序获取分栏文档的文本坐标。
- 支持为 PdfStringFormat 设置 HorizontalScalingFactor 属性。
- 支持在转换有权限密码的PDF时设置是否允许转换。
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(input);
PdfPageBase pdfPageBase = doc.Pages[0];
PdfTextFinder finder = new PdfTextFinder(pdfPageBase);
finder.Options.Strategy = PdfTextStrategy.Simple;
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
string text = "Please add the code picture BehindText=true to set the picture behind text";
PdfSolidBrush solidBrush = new PdfSolidBrush (new PdfRGBColor(Color.Black));
PdfStringFormat format = new PdfStringFormat():
format.HorizontalScalingFactor = 80;
PdfFont font = new PdfFont(PdfFontFamily.TimesRoman, 14f, PdfFontStyle.Regular);
PdfGraphicsState state = page.Canvas.Save();
page.Canvas.DrawString(text, font, solidBrush, 0, 0, format);
page.Canvas.Restore(state):
doc.SaveToFile(outputFile);
doc.Close();
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFile);
doc.ConvertOptions.ApplyPermissionsOptions(true);
StringBuilder sb = new StringBuilder();
foreach (FileFormat type in Enum.GetValues(typeof(FileFormat)))
{
try
{
if (type.ToString().Equals("PDF"))
{
doc.SaveToFile(outputFile_P, type);
}
else
{
doc.SaveToFile(outputFile, type);
}
}
catch (Exception ex)
{
sb.AppendLine("save to: "+ type +" :"+ ex.Message);
}
}
File.AppendAllText(outputFile,sb.ToString());
doc.Dispose();
问题修复:
- 修复了提取的表格数据格式不正确的问题。
- 修复了给表格设置单元格间距后,输出结果不正确的问题。
- 修复了XFA的文本框表单域填充不成功的问题。
- 修复了程序在合并PDF文件时抛出“System.IO.IOExceptions:Stream was too long”异常的问题。
- 修复了填充textbox域后字体应用不正确的问题。
- 修复了有权限密码的PDF转换到Word时没有请求输入权限密码的问题。
- 修复了程序在转OFD到PDF文件时抛出“System.NullReferenceException”异常的问题。
- 修复了“new PdfGoToAction(partBookmarkDest)”不生效的问题。
Spire.Doc
新功能:
- 新增了转换Word到PDF时文本整形的功能(主要针对泰文字符和藏语字符等做了处理),且支持 .NET 4.6.2及以上、.NET Core 和 .NET Standard平台。
Document doc = new Document();
doc.LoadFromFile(fileName);
doc.LayoutOptions.UseHarfBuzzTextShaper = true;
doc.SaveToFile(pdfFileName, Spire.Doc.FileFormat.PDF)
问题修复:
- 修复了将Word转换为PDF时泰语字符未对齐和换行的问题。
Spire.XLS
新功能:
- 提升Excel到PDF的转换效率。
- 支持自定义透视表字段的名称。
sheet.PivotTables[0].RowFields[0].CustomName = "rowName";
sheet.PivotTables[0].ColumnFields[0].CustomName = "colName";
sheet.PivotTables[0].PivotFields[0].CustomName = "fieldName1";
sheet.PivotTables[0].DataFields[0].CustomName = "dataName";
问题修复:
- 修复了转换Excel到HTML后图片位置改变的问题。
- 修复了被删除的注释没有从文档中移除成功的问题。
- 修复了读取Excel文档时程序抛出System.OverflowException异常的问题。
Spire.Presentation
新功能:
- 支持获取形状内文本的位置信息。
- 支持获取形状中文本的“Ascent”和“Descent”属性。
- 支持将形状转换为SVG格式。
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
StringBuilder sb = new StringBuilder();
ISlide slide = ppt.Slides[0];
for (int i = 0; i < slide.Shapes.Count; i++)
{
IShape shape = slide.Shapes[i];
if (shape is IAutoShape)
{
IAutoShape autoshape = slide.Shapes[i] as IAutoShape;
string text = autoshape.TextFrame.Text;
//obtain the text position information
PointF point = autoshape.TextFrame.GetTextLocation();
sb.AppendLine("Shape " + i + ":" + text + "\r\n" + "location:" + point.ToString());
}
}
File.AppendAllText(outputFile, sb.ToString());
ppt.Dispose();
Presentation ppt = new Presentation();
ppt.LoadFromFile(inputFile);
ISlide slide = ppt.Slides[0];
IAutoShape autoshape = slide.Shapes[0] as IAutoShape;
IList<LineText> lines = autoshape.TextFrame.GetLayoutLines();
for (int i = 0; i < lines.Count; i++)
{
float ascent= lines[i].Ascent;
float descent = lines[i].Descent;
}
Presentation ppt = new Presentation();
ppt.LoadFromFile("FreeForm.pptx");
ISlide slide = ppt.Slides[0];
int num = 0;
foreach (IShape shape in slide.Shapes)
{
byte[] svgByte = shape.SaveAsSvg();
FileStream fs = new FileStream("shape_" + num + ".svg",FileMode.Create);
fs.Write(svgByte, 0, svgByte.Length);
fs.Close();
num++;
}
问题修复:
- 修复了将PPT转换为SVG后,用浏览器打开SVG文件时出现空白的问题。