本文介绍如何使用Spire.PDF for Java为PDF文档添加数字签名时添加一个可信时间戳。
import com.spire.pdf.PdfDocument;
import com.spire.pdf.graphics.*;
import com.spire.pdf.security.GraphicMode;
import com.spire.pdf.security.PdfCertificate;
import com.spire.pdf.security.PdfCertificationFlags;
import com.spire.pdf.security.PdfSignature;
import java.awt.*;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public class SignWithTimestamp {
public static void main(String[] args) {
//加载PDF文档
PdfDocument doc = new PdfDocument();
doc.loadFromFile("https://cdn.e-iceblue.cn/C:\\Users\\Administrator\\Desktop\\Introduction.pdf");
//加载pfx文档
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\gary.pfx", "e-iceblue");
//添加数字签名,设置其位置和大小
PdfSignature signature = new PdfSignature(doc, doc.getPages().get(0), cert, "MySignature");
Rectangle2D rect = new Rectangle2D.Float();
rect.setFrame(new Point2D.Float((float) doc.getPages().get(0).getActualSize().getWidth() - 220, (float) doc.getPages().get(0).getActualSize().getHeight() - 140), new Dimension(200, 100));
signature.setBounds(rect);
//设置签名为文本模式
signature.setGraphicMode(GraphicMode.Sign_Detail);
//设置签名的内容
signature.setNameLabel("签字者:");
signature.setName("Gary");
signature.setContactInfoLabel("联系电话:");
signature.setContactInfo("02881705109");
signature.setLocationInfoLabel("地点:");
signature.setLocationInfo("成都");
signature.setReasonLabel("原因:");
signature.setReason("我是文档所有者");
//设置签名的字体
signature.setSignDetailsFont(new PdfTrueTypeFont(new Font("宋体", Font.PLAIN, 12)));
//设置文档权限为禁止更改
signature.setDocumentPermissions(PdfCertificationFlags.Forbid_Changes);
signature.setCertificated(true);
//配置时间戳服务器
String timestampeServerUrl = "http://timestamp.digicert.com";
signature.configureTimestamp(timestampeServerUrl);
//保存文档
doc.saveToFile("output/Timestamp.pdf");
doc.close();
}
}

Spire.Barcode 5.7.1现已发布。该版本支持获取条码在图片中的位置和条码类型,同时还修复了扫描图片程序挂起和扫描结果不正确的问题。详情如下。
新功能:
BarcodeInfo[] barcodeInfos = BarcodeScanner.ScanInfo(imageFile);
//BarcodeInfo[] barcodeInfos = BarcodeScanner.ScanInfo(imageFile, barCodeType);
for (int i = 0; i < barcodeInfos.Length; i++)
{
//获取条码位置
BarCodeReadType barCodeReadType = barcodeInfos[i].BarCodeReadType;
//获取条码四个顶点的坐标
Point[] vertexes = barcodeInfos[i].Vertexes;
}
问题修复:
Spire.Presentation 6.7.2已正式发布。该版本支持设置图表坐标轴的刻度线间隔,并新增了LoadFromStream重载方法支持从流加载加密的文档,同时修复了转换PPT到PDF,OLE图标不正确的问题。新功能及问题修复详情如下。
新功能:
Presentation ppt = new Presentation();
ppt.LoadFromFile(intputFile);
IChart chart = ppt.Slides[0].Shapes[0] as IChart;
IChartAxis chartAxis = chart.PrimaryCategoryAxis;
chartAxis.TickMarkSpacing = 30;
ppt.SaveToFile(outputFile, FileFormat.Pptx2013);
FileStream from_stream = File.OpenRead(inputFile);
Presentation presentation = new Presentation();
presentation.LoadFromStream(from_stream,FileFormat.Auto, "12345");
presentation.SaveToFile(outputFile_px, FileFormat.Pptx2013);
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html
本文将介绍如何使用Spire.PDF for Java提取PDF文件包(Portfolio)中的文件。
原PDF文档:

import com.spire.pdf.PdfDocument;
import com.spire.pdf.attachments.PdfAttachment;
import java.io.*;
public class ReadPortfolio {
public static void main(String []args) throws IOException {
//创建PdfDocument实例
PdfDocument pdf = new PdfDocument();
//加载PDF文档
pdf.loadFromFile("https://cdn.e-iceblue.cn/Portfolio.pdf");
//遍历文档中的附件
for(Object obj : pdf.getAttachments()) {
PdfAttachment attachment = (PdfAttachment) obj;
//提取附件
String fileName = attachment.getFileName();
OutputStream fos = new FileOutputStream("extract/" + fileName);
fos.write(attachment.getData());
}
pdf.dispose();
}
}
运行结果:

本文介绍使用Spire.XLS for .NET判断Excel中的指定行或列是否隐藏。
用于测试的Excel文档如图,隐藏了第3行和F列(第6列)的数据:

using Spire.Xls;
namespace DetectHiddenRowOrColumn_XLS
{
class Program
{
static void Main(string[] args)
{
//加载Excel工作簿
Workbook wb = new Workbook();
wb.LoadFromFile("sample.xlsx");
//获取第一张工作表
Worksheet sheet = wb.Worksheets[0];
//判断第3行是否隐藏
bool result = sheet.GetRowIsHide(3);
//sheet.GetColumnIsHide(6);//判断第6列是否隐藏
if (result == true)
{
System.Console.WriteLine("隐藏");
System.Console.ReadLine();
}
else
{
System.Console.WriteLine("未隐藏");
System.Console.ReadLine();
}
}
}
}

Imports Spire.Xls
Namespace DetectHiddenRowOrColumn_XLS
Class Program
Private Shared Sub Main(args As String())
'加载Excel工作簿
Dim wb As New Workbook()
wb.LoadFromFile("sample.xlsx")
'获取第一张工作表
Dim sheet As Worksheet = wb.Worksheets(0)
'判断第3行是否隐藏
Dim result As Boolean = sheet.GetRowIsHide(3)
'sheet.GetColumnIsHide(6);//判断第5列是否隐藏
If result = True Then
System.Console.WriteLine("隐藏")
System.Console.ReadLine()
Else
System.Console.WriteLine("未隐藏")
System.Console.ReadLine()
End If
End Sub
End Class
End Namespace 本文介绍使用Spire.PDF for .NET来设置PDF表格跨页时,重复显示表头行的方法。
using Spire.Pdf;
using Spire.Pdf.Graphics;
using Spire.Pdf.Grid;
using System.Drawing;
namespace RepeatTableHeaderRow
{
class Program
{
static void Main(string[] args)
{
//新建一个PDF文档
PdfDocument pdf = new PdfDocument();
//添加一页
PdfPageBase page = pdf.Pages.Add();
//创建PdfGrid类的对象
PdfGrid grid = new PdfGrid();
//设置单元格填充
grid.Style.CellPadding = new PdfPaddings(1, 1, 1, 1);
//添加表格列数
grid.Columns.Add(3);
//添加表头行及表格数据
PdfGridRow[] pdfGridRows = grid.Headers.Add(1);
for (int i = 0; i < pdfGridRows.Length; i++)
{
pdfGridRows[i].Style.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Regular), true);//指定字体
pdfGridRows[i].Cells[0].Value = "NAME";
pdfGridRows[i].Cells[1].Value = "SUBJECT";
pdfGridRows[i].Cells[2].Value = "SCORES";
pdfGridRows[i].Style.TextBrush = PdfBrushes.Red;
}
//设置重复表头(表格跨页时)
grid.RepeatHeader = true;
//添加数据到表格
for (int i = 0; i < 60; i++)
{
PdfGridRow row = grid.Rows.Add();
for (int j = 0; j < grid.Columns.Count; j++)
{
row.Cells[j].Value = "(Row " + i + ", column " + j + ")";
}
}
//在PDF页面绘制表格
grid.Draw(page, new PointF(0, 20));
//保存文档
pdf.SaveToFile("Result.pdf");
System.Diagnostics.Process.Start("Result.pdf");
}
}
}
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports Spire.Pdf.Grid
Imports System.Drawing
Namespace RepeatTableHeaderRow
Class Program
Private Shared Sub Main(args As String())
'新建一个PDF文档
Dim pdf As New PdfDocument()
'添加一页
Dim page As PdfPageBase = pdf.Pages.Add()
'创建PdfGrid类的对象
Dim grid As New PdfGrid()
'设置单元格填充
grid.Style.CellPadding = New PdfPaddings(1, 1, 1, 1)
'添加表格列数
grid.Columns.Add(3)
'添加表头行及表格数据
Dim pdfGridRows As PdfGridRow() = grid.Headers.Add(1)
For i As Integer = 0 To pdfGridRows.Length - 1
pdfGridRows(i).Style.Font = New PdfTrueTypeFont(New Font("Arial", 11F, FontStyle.Regular), True)
'指定字体
pdfGridRows(i).Cells(0).Value = "NAME"
pdfGridRows(i).Cells(1).Value = "SUBJECT"
pdfGridRows(i).Cells(2).Value = "SCORES"
pdfGridRows(i).Style.TextBrush = PdfBrushes.Red
Next
'设置重复表头(表格跨页时)
grid.RepeatHeader = True
'添加数据到表格
For i As Integer = 0 To 59
Dim row As PdfGridRow = grid.Rows.Add()
For j As Integer = 0 To grid.Columns.Count - 1
row.Cells(j).Value = "(Row " + i + ", column " + j + ")"
Next
Next
'在PDF页面绘制表格
grid.Draw(page, New PointF(0, 20))
'保存文档
pdf.SaveToFile("Result.pdf")
System.Diagnostics.Process.Start("Result.pdf")
End Sub
End Class
End Namespace
文档效果:

Spire.Office 6.7.0已发布。本次更新带来2个新功能,即Spire.XLS支持判断单元格是否设置了自适应行高/列宽,以及获取.xls格式文档中的几何形状。同时,该版本还修复了一些在操作Word、PDF、Excel、PowerPoint时出现的问题。详情请阅读以下内容。
该版本涵盖了最新版的Spire.Doc, Spire.PDF, Spire.XLS, Spire.Presentation, Spire.Email, Spire.DocViewer, Spire.PDFViewer, Spire.Spreadsheet, Spire.OfficeViewer, Spire.DataExport, Spire.Barcode。
版本信息如下:
https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html
问题修复:
问题修复:
问题修复:
新功能:
bool isRowAutofit = workbook.Worksheets[0].GetRowIsAutoFit(rowIndex);
bool isColAutofit = workbook.Worksheets[0].GetColumnIsAutoFit(columnIndex);
Workbook workbook = new Workbook();
workbook.LoadFromFile("Template.xls");
Worksheet sheet = workbook.Worksheets[0];
PrstGeomShapeCollection prstGeomShapes = sheet.PrstGeomShapes;
问题修复:
问题修复:
Spire.XLS 11.7.0已正式发布。该版本支持获取单元格是否设置了自适应行高/列宽、获取.xls格式文档中的几何形状等新功能;并修复了将Excel转为PDF、加载及保存文档时出现的问题。新功能及问题修复详情如下。
新功能:
bool isRowAutofit = workbook.Worksheets[0].GetRowIsAutoFit(rowIndex);
bool isColAutofit = workbook.Worksheets[0].GetColumnIsAutoFit(columnIndex);
Workbook workbook = new Workbook();
workbook.LoadFromFile("Template.xls");
Worksheet sheet = workbook.Worksheets[0];
PrstGeomShapeCollection prstGeomShapes = sheet.PrstGeomShapes;
问题修复:
本文介绍如何使用Spire.PDF for Java来实现PDF表格跨页时重复显示表头行。
import com.spire.pdf.*;
import com.spire.pdf.graphics.*;
import com.spire.pdf.grid.PdfGrid;
import com.spire.pdf.grid.PdfGridRow;
import java.awt.*;
public class RepeatTableHeaderRow {
public static void main(String[] args) {
//新建一个PDF文档
PdfDocument pdf = new PdfDocument();
//添加一页
PdfPageBase page = pdf.getPages().add();
//创建PdfGrid类的对象
PdfGrid grid = new PdfGrid();
//设置单元格填充
grid.getStyle().setCellPadding(new PdfPaddings(1,1,1,1));
//添加表格列数
grid.getColumns().add(3);
//添加表头行及表格数据
PdfGridRow[] pdfGridRows = grid.getHeaders().add(1);
for (int i = 0; i < pdfGridRows.length; i++)
{
pdfGridRows[i].getStyle().setFont(new PdfTrueTypeFont(new Font("Arial", Font.PLAIN,12), true));//指定字体
pdfGridRows[i].getCells().get(0).setValue("NAME");
pdfGridRows[i].getCells().get(1).setValue("SUBJECT");
pdfGridRows[i].getCells().get(2).setValue("SCORES");
pdfGridRows[i].getStyle().setTextBrush(PdfBrushes.getRed());
}
//设置重复表头(表格跨页时)
grid.setRepeatHeader(true);
//添加数据到表格
for (int i = 0; i < 60; i++)
{
PdfGridRow row = grid.getRows().add();
for (int j = 0; j < grid.getColumns().getCount();j++)
{
row.getCells().get(j).setValue("(Row " + (i+1) + ", column " + (j+1) + ")");
}
}
//在PDF页面绘制表格
grid.draw(page,0,40);
//保存文档
pdf.saveToFile("Result.pdf");
pdf.dispose();
}
}
效果如图:

Spire.Doc 9.7.3现已发布。 此次更新增强了转换Word到PDF及转换Html到Word 的功能,同时还修复了一些在加载、保存、打印Word文档时出现的问题。具体修复内容如下。
问题修复: