Spire.Presentation for Java 3.5.4已发布。该版本新增了支持在形状中获取文本输入区域的最大宽度,以及获取形状中文本输入区域的宽度最大时文本的起始坐标等功能。此外,也成功修复了在将PPTX文档转换成图片、获取表格单元格中文本颜色、加载文件以及设置数据表格边框时出现的一些问题。新功能及问题修复详情见下文。
新功能:
IAutoShape shape = (IAutoShape) ppt.getSlides().get(0).getShapes().get(0);
float maxWidth = shape.getTextFrame().getMaxWidth();
IAutoShape shape = (IAutoShape) ppt.getSlides().get(0).getShapes().get(0);
double x = shape.getTextFrame().getStartLocationAtMaxWidth().getX();
double y = shape.getTextFrame().getStartLocationAtMaxWidth().getY();
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-JAVA.html
本文展示如何使用Spire.XLS for Java隐藏Excel图表中的网格线。
import com.spire.xls.*;
public class HideGridlinesInChart {
public static void main(String[] args) {
//创建Workbook对象
Workbook workbook = new Workbook();
//加载用于生成图表的文档
workbook.loadFromFile("C:\\Users\\Administrator\\Desktop\\data.xlsx");
//获取第一个工作表
Worksheet sheet = workbook.getWorksheets().get(0);
//创建柱状图
Chart chart = sheet.getCharts().add(ExcelChartType.ColumnClustered);
//设置图表数据区域
chart.setDataRange(sheet.getCellRange("A1:C5"));
chart.setSeriesDataFromRange(false);
//设置图表位置
chart.setLeftColumn(1);
chart.setTopRow(6);
chart.setRightColumn(8);
chart.setBottomRow(19);
//隐藏图表的网格线
chart.getPrimaryValueAxis().hasMajorGridLines(false);
//保存文档
workbook.saveToFile("HideGridlines.xlsx", ExcelVersion.Version2010);
}
}

Spire. Office 5.5.1已正式发布。该版本新增加了一些功能,如Spire.PDF支持添加和转换SVG图片到PDF,支持创建PDF Portfolios;Spire.Doc支持获取表格以及表格单元格的对角线边框属性;Spire.XLS支持转换HTML到Excel。与此同时,一些在加载、转换和操作PDF、Word、Excel文档时出现的问题也得以成功解决。新功能及问题修复详情如下。
该版本涵盖了最新版的Spire.Doc、Spire.PDF、Spire.XLS、Spire.Presentation、Spire.DataExport、Spire.Barcode、Spire.DocViewer、Spire.PDFViewer、Spire.OfficeViewer、Spire.Email。
版本信息如下:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
新功能:
PdfDocument doc1 = new PdfDocument();
doc1.LoadFromSvg(inputFile_svg);
PdfDocument doc2 = new PdfDocument();
doc2.LoadFromFile(inputFile_pdf);
PdfTemplate template = doc1.Pages[0].CreateTemplate();
template.Draw(doc2.Pages[0].Canvas, new PointF());
doc2.SaveToFile(outputFile, FileFormat.PDF);
PdfDocument doc = new PdfDocument();
doc.LoadFromSvg("https://cdn.e-iceblue.cn/test.svg");
doc.SaveToFile("result.pdf", FileFormat.PDF);
String[] files = new String[] { "File1.pdf", "File2.pdf" };
using (PdfDocument doc = new PdfDocument())
{
for (int i = 0; i < files.Length; i++)
{
doc.Collection.AddFile(files[i]);
}
doc.SaveToFile("output.pdf", FileFormat.PDF);
doc.Dispose();
}
//创建子文件夹并向其添加文件
string[] files = Directory.GetFiles(@"input/");
string inputFile_1 = "input.pdf";
using (PdfDocument doc = new PdfDocument(inputFile_1))
{
for (int i = 0; i < files.Length; i++)
{
doc.Collection.Folders.AddFile(files[i]);
PdfFolder folder = doc.Collection.Folders.CreateSubfolder("SubFolder" + i);
folder.AddFile(files[i]);
}
doc.SaveToFile("output.pdf", FileFormat.PDF);
doc.Dispose();
}
问题修复:
新功能:
//获取表格的对角线属性
BorderStyle bs_UP = table.TableFormat.Borders.DiagonalUp.BorderType;
Color color_UP = table.TableFormat.Borders.DiagonalUp.Color;
float width_UP = table.TableFormat.Borders.DiagonalUp.LineWidth;
BorderStyle bs_Down = table.TableFormat.Borders.DiagonalDown.BorderType;
Color color_Down = table.TableFormat.Borders.DiagonalDown.Color;
float width_Down = table.TableFormat.Borders.DiagonalDown.LineWidth;
//获取表格单元格的对角线属性
bs_UP = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalUp.BorderType;
width_UP = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalUp.LineWidth;
color_UP = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalUp.Color;
bs_Down = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalDown.BorderType;
color_Down = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalDown.Color;
width_Down = table[rowIndex, columnIndex].CellFormat.Borders.DiagonalDown.LineWidth;
问题修复:
新功能:
workbook.LoadFromHtml(string fileName);
workbook.LoadFromHtml(Stream stream);
workbook.LoadFromMHtml(string fileName);
workbook.LoadFromMHtml(Stream stream);
问题修复:
Spire.XLS 10.5.7已发布。该版本添加了新功能支持转换HTML到Excel,同时也修复了一些在转换Excel到PDF、HTML以及转换XML到Excel时出现的问题。
新功能:
workbook.LoadFromHtml(string fileName);
workbook.LoadFromHtml(Stream stream);
workbook.LoadFromMHtml(string fileName);
workbook.LoadFromMHtml(Stream stream);
问题修复:
PDF文件包(Portfolio)允许用户将多种不同类型的文件如Word、Excel、PDF、PowerPoint和图片等集合到一个PDF文件中,用户可以打开、更改PDF文件包中的单个文件,而不影响其他文件。本文将介绍如何使用Spire.PDF for .NET创建PDF文件包。
在创建PDF文件包时,Spire.PDF for .NET支持给包添加文件和文件夹。以下示例展示了如何使用Spire.PDF for .NET创建PDF文件包并添加文件。
using System;
using Spire.Pdf;
namespace CreatePDFPortfolio
{
class Program
{
static void Main(string[] args)
{
String[] files = new String[] { "Instruction.pdf", "Sales Report.docx", "Sample.xlsx" };
//创建PdfDocument实例
using (PdfDocument doc = new PdfDocument())
{
//创建PDF文件包并添加文件
for (int i = 0; i < files.Length; i++)
{
doc.Collection.AddFile(files[i]);
}
//保存结果文档
doc.SaveToFile("PortfolioWithFiles.pdf", FileFormat.PDF);
doc.Dispose();
}
}
}
}
Imports System
Imports Spire.Pdf
Namespace CreatePDFPortfolio
Class Program
Private Shared Sub Main(ByVal args As String())
Dim files As String() = New String() {"Instruction.pdf", "Sales Report.docx", "Sample.xlsx"}
Using doc As PdfDocument = New PdfDocument()
For i As Integer = 0 To files.Length - 1
doc.Collection.AddFile(files(i))
Next
doc.SaveToFile("PortfolioWithFiles.pdf", FileFormat.PDF)
doc.Dispose()
End Using
End Sub
End Class
End Namespace

以下示例展示了如何使用Spire.PDF for .NET创建PDF文件包并添加文件夹。
using System;
using Spire.Pdf;
using Spire.Pdf.Collections;
namespace CreatePDFPortfolio
{
class Program
{
static void Main(string[] args)
{
String[] files = new String[] { "Instruction.pdf", "Sales Report.docx", "Sample.xlsx" };
//创建PdfDocument实例
using (PdfDocument doc = new PdfDocument())
{
//创建PDF文件包,添加文件夹并向文件夹添加文件
for (int i = 0; i < files.Length; i++)
{
PdfFolder folder = doc.Collection.Folders.CreateSubfolder("Folder" + i);
folder.AddFile(files[i]);
}
//保存结果文档
doc.SaveToFile("PortfolioWithFolders.pdf", FileFormat.PDF);
doc.Dispose();
}
}
}
}
Imports System
Imports Spire.Pdf
Imports Spire.Pdf.Collections
Namespace CreatePDFPortfolio
Class Program
Private Shared Sub Main(ByVal args As String())
Dim files As String() = New String() {"Instruction.pdf", "Sales Report.docx", "Sample.xlsx"}
Using doc As PdfDocument = New PdfDocument()
For i As Integer = 0 To files.Length - 1
Dim folder As PdfFolder = doc.Collection.Folders.CreateSubfolder("Folder" & i)
folder.AddFile(files(i))
Next
doc.SaveToFile("PortfolioWithFolders.pdf", FileFormat.PDF)
doc.Dispose()
End Using
End Sub
End Class
End Namespace

Spire.Doc for Java 3.5.2已发布。该版本主要修复了在加载Word文档、更新Word目录域以及将HTML转为Word时出现的一些问题。详情如下。
问题修复:
本文介绍使用Spire.PDF for Java在PDF文档中设置文本倾斜、旋转的方法。
import com.spire.pdf.*;
import com.spire.pdf.graphics.*;
import java.awt.*;
public class TextStyle {
public static void main(String[] args) {
//创建PDF文档,添加一页
PdfDocument pdf = new PdfDocument();
PdfPageBase page = pdf.appendPage();
//设置文本倾斜
TransformText(page);
//旋转文本
RotateText(page);
//保存文档
pdf.saveToFile("DrawText.pdf",FileFormat.PDF);
pdf.close();
}
//自定义方法在页面添加文本,并设置文本倾斜
private static void TransformText(PdfPageBase page)
{
PdfGraphicsState state = page.getCanvas().save();//保存画布状态
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);//创建字体,包括字体、字号等
//创建三个画刷,并指定颜色
PdfSolidBrush brush1 = new PdfSolidBrush(new PdfRGBColor(new Color(60,179,113)));
PdfSolidBrush brush2 = new PdfSolidBrush(new PdfRGBColor(new Color(139,0,139)));
PdfSolidBrush brush3 = new PdfSolidBrush(new PdfRGBColor(new Color(205,92,92)));
page.getCanvas().translateTransform(20,120);//设置文本在画布中的坐标位置
page.getCanvas().scaleTransform(1f,1f);//设置文本大小(scaleX值越大,文本越向右横向拉伸;scaleY值越大,文本越向上纵向拉伸)
page.getCanvas().skewTransform(-10,0);//设置文本偏转角度(angleX值为文本整体偏移角度,angleY值为字符偏移角度)
page.getCanvas().drawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);//绘制文本
page.getCanvas().skewTransform(10, 10);
page.getCanvas().drawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);//绘制文本
page.getCanvas().scaleTransform(1f, -2f);
page.getCanvas().drawString("Go! Turn Around! Go! Go! Go!", font, brush3, 0, -2 * 18);//绘制文本
//再次保存画布状态
page.getCanvas().restore(state);
}
//自定义方法在页面添加文本,并设置文本旋转
private static void RotateText(PdfPageBase page)
{
PdfGraphicsState state = page.getCanvas().save();//保存画布状态
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 10f);//创建字体
PdfSolidBrush brush4 = new PdfSolidBrush(new PdfRGBColor(139,69,19));//创建画刷4
PdfStringFormat centerAlignment = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);//设置文本对齐方式
//指定文本在画布中的坐标位置
float x = (float) (page.getCanvas().getClientSize().getWidth()/2);
float y = 390;
page.getCanvas().translateTransform(x,y);
for (int i = 0; i < 12; i++){
page.getCanvas().rotateTransform(30); //设置顺时针旋转角度
page.getCanvas().drawString("Go! Turn Around! Go! Go! Go!", font, brush4, 20, 0, centerAlignment);
}
//再次保存画布状态
page.getCanvas().restore(state);
}
}
设置结果:

前面我们介绍了如何 将PDF保存为SVG图片。该文将详细介绍如何使用C#/VB.NET添加SVG图片到PDF和将SVG图片保存为PDF。
将SVG图片保存为PDF
源SVG图片如下:

using Spire.Pdf;
namespace SVGtoPDF
{
class Program
{
static void Main(string[] args)
{
PdfDocument doc = new PdfDocument();
doc.LoadFromSvg("https://cdn.e-iceblue.cn/Sample.svg");
doc.SaveToFile("Result.pdf", FileFormat.PDF);
}
}
}
Imports Spire.Pdf
Namespace SVGtoPDF
Class Program
Private Shared Sub Main(ByVal args() As String)
Dim doc As PdfDocument = New PdfDocument
doc.LoadFromSvg("https://cdn.e-iceblue.cn/Sample.svg")
doc.SaveToFile("Result.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace
效果图:

添加SVG图片到PDF
将已有的SVG图片插入到PDF时,我们还可以设置SVG图片的位置和大小:
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace AddSVGImagetoPDF
{
class Program
{
static void Main(string[] args)
{
PdfDocument doc1 = new PdfDocument();
doc1.LoadFromSvg("https://cdn.e-iceblue.cn/Sample.svg");
PdfDocument doc2 = new PdfDocument();
doc2.LoadFromFile("Sample2.pdf");
PdfTemplate template = doc1.Pages[0].CreateTemplate();
//template.Draw(doc2.Pages[0].Canvas, new PointF());
//设置图片位置和大小
doc2.Pages[0].Canvas.DrawTemplate(doc1.Pages[0].CreateTemplate(), new PointF(80, 80), new SizeF(300, 300));
doc2.SaveToFile("Result0.pdf", FileFormat.PDF);
}
}
}
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing
Namespace AddSVGImagetoPDF
Class Program
Private Shared Sub Main(ByVal args() As String)
Dim doc1 As PdfDocument = New PdfDocument
doc1.LoadFromSvg("https://cdn.e-iceblue.cn/Sample.svg")
Dim doc2 As PdfDocument = New PdfDocument
doc2.LoadFromFile("Sample2.pdf")
Dim template As PdfTemplate = doc1.Pages(0).CreateTemplate
'template.Draw(doc2.Pages[0].Canvas, new PointF());
'设置图片位置和大小
doc2.Pages(0).Canvas.DrawTemplate(doc1.Pages(0).CreateTemplate, New PointF(80, 80), New SizeF(300, 300))
doc2.SaveToFile("Result0.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace
效果图:

Spire.PDF 6.5.9 现已正式发布。该版本支持创建PDF Portfolios,同时一些在显示、打印和验证PDF文档时出现的问题也得以成功解决。新功能及问题修复详情,请查阅以下内容。
新功能:
String[] files = new String[] { "File1.pdf", "File2.pdf" };
using (PdfDocument doc = new PdfDocument())
{
for (int i = 0; i < files.Length; i++)
{
doc.Collection.AddFile(files[i]);
}
doc.SaveToFile("output.pdf", FileFormat.PDF);
doc.Dispose();
}
//创建子文件夹并向其添加文件
string[] files = Directory.GetFiles(@"input/");
string inputFile_1 = "input.pdf";
using (PdfDocument doc = new PdfDocument(inputFile_1))
{
for (int i = 0; i < files.Length; i++)
{
doc.Collection.Folders.AddFile(files[i]);
PdfFolder folder = doc.Collection.Folders.CreateSubfolder("SubFolder" + i);
folder.AddFile(files[i]);
}
doc.SaveToFile("output.pdf", FileFormat.PDF);
doc.Dispose();
}
问题修复:
在Excel中,我们可以选中含有批注的单元格,右键并点击“显示/隐藏批注”选项来更改该批注的显示状态。本文将介绍如何使用Spire.XLS for Java实现在Excel文档中隐藏或显示批注。
原Excel文档:

import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;
public class HideOrShowComments {
public static void main(String[] args){
//创建Workbook实例
Workbook workbook = new Workbook();
//加载Excel文档
workbook.loadFromFile("CommentExample.xlsx");
//获取第一张工作表
Worksheet sheet = workbook.getWorksheets().get(0);
//隐藏工作表中第一、二个批注
sheet.getComments().get(0).isVisible(false);
sheet.getComments().get(1).isVisible(false);
//显示第三个批注
sheet.getComments().get(2).isVisible(true);
//保存结果文档
workbook.saveToFile("HideOrShowComment.xlsx", ExcelVersion.Version2013);
}
}
结果文档:
