本文介绍如何使用Spire.PDF从URL地址中下载PDF文档。
using System.IO;
using System.Net;
using Spire.Pdf;
namespace DownloadPdfFromUrl
{
class Program
{
static void Main(string[] args)
{
//创建PdfDocument对象
PdfDocument doc = new PdfDocument();
//创建WebClient对象
WebClient webClient = new WebClient();
//从URL地址下载PDF数据,并保存为流
using (MemoryStream ms = new MemoryStream(webClient.DownloadData("http://www.e-iceblue.com/images/sample.pdf")))
{
//加载流
doc.LoadFromStream(ms);
}
//保存为PDF文档
doc.SaveToFile("result.pdf", FileFormat.PDF);
}
}
}
Imports System.IO
Imports System.Net
Imports Spire.Pdf
Namespace DownloadPdfFromUrl
Class Program
Shared Sub Main(ByVal args() As String)
'创建PdfDocument对象
Dim doc As PdfDocument = New PdfDocument()
'创建WebClient对象
Dim webClient As WebClient = New WebClient()
'从URL地址下载PDF数据,并保存为流
Imports(MemoryStream ms = New MemoryStream(webClient.DownloadData("http:'www.e-iceblue.com/images/sample.pdf")))
{
'加载流
doc.LoadFromStream(ms)
}
'保存为PDF文档
doc.SaveToFile("result.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace

之前我们介绍了如何插入和读取Excel文本批注,该文将介绍如何使用Spire.XLS for Java给Excel文档添加图片批注。
import com.spire.xls.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
public class Test {
public static void main(String[] args)throws IOException {
//加载示例文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Sample.xlsx");
//获取第一个工作表
Worksheet sheet = workbook.getWorksheets().get(0);
//设置字体
ExcelFont font = workbook.createFont();
font.setFontName("Arial");
font.setSize(11);
font.setKnownColor(ExcelColors.Orange);
CellRange range = sheet.getCellRange("D1");
//添加批注
ExcelComment comment = range.addComment();
//加载图片
BufferedImage bufferedImage = ImageIO.read(new File("Logo.jpg"));
//使用图片填充批注
comment.getFill().customPicture(bufferedImage, "Logo.jpg");
//设置批注高度和宽度
comment.setHeight(bufferedImage.getHeight());
comment.setWidth(bufferedImage.getWidth());
//设置批注可见
comment.setVisible(true);
//保存文档
workbook.saveToFile("output/setimageComment.xlsx", ExcelVersion.Version2013);
}
}
效果图:

本文介绍如何使用Spire.Presentation for Java在PPT幻灯片中设置自定义动画路径。
import com.spire.presentation.*;
import com.spire.presentation.collections.CommonBehaviorCollection;
import com.spire.presentation.drawing.FillFormatType;
import com.spire.presentation.drawing.animation.*;
import java.awt.*;
import java.awt.geom.Point2D;
public class CustomAnimationPath {
public static void main(String[] args) throws Exception {
//创建一个空白PPT文档
Presentation ppt = new Presentation();
//获取第一张幻灯片(新建的幻灯片文档默认已包含一张幻灯片)
ISlide slide = ppt.getSlides().get(0);
//添加形状到幻灯片
IAutoShape shape = slide.getShapes().appendShape(ShapeType.FIVE_POINTED_STAR,new Rectangle(180, 100, 170, 170));
shape.getFill().setFillType(FillFormatType.GRADIENT);
shape.getFill().getGradient().getGradientStops().append(0, KnownColors.LIGHT_PINK);
shape.getFill().getGradient().getGradientStops().append(1, KnownColors.PURPLE);
shape.getShapeStyle().getLineColor().setColor(Color.white);
//添加动画效果,并设置动画效果类型为PATH_USER(自定义类型)
AnimationEffect effect = slide.getTimeline().getMainSequence().addEffect(shape, AnimationEffectType.PATH_USER);
//获取自定动画的CommonBehavior集合
CommonBehaviorCollection commonBehaviorCollection = effect.getCommonBehaviorCollection();
//设置动画动作运动起点及路径模式
AnimationMotion motion = (AnimationMotion)commonBehaviorCollection.get(0);
motion.setOrigin(AnimationMotionOrigin.LAYOUT);
motion.setPathEditMode(AnimationMotionPathEditMode.RELATIVE);
//设置动作路径
MotionPath motionPath = new MotionPath();
motionPath.addPathPoints(MotionCommandPathType.MOVE_TO,new Point2D.Float[]{new Point2D.Float(0,0)},MotionPathPointsType.CURVE_AUTO,true);
motionPath.addPathPoints(MotionCommandPathType.LINE_TO,new Point2D.Float[]{new Point2D.Float(0.1f,0.1f)},MotionPathPointsType.CURVE_AUTO,true);
motionPath.addPathPoints(MotionCommandPathType.LINE_TO,new Point2D.Float[]{new Point2D.Float(-0.1f,0.2f)},MotionPathPointsType.CURVE_AUTO,true);
motionPath.addPathPoints(MotionCommandPathType.END,new Point2D.Float[]{},MotionPathPointsType.CURVE_AUTO,true);
//设置动作路径到动画
motion.setPath(motionPath);
//保存文档
ppt.saveToFile("result.pptx", FileFormat.PPTX_2013);
ppt.dispose();
}
}
设置结果:

Spire.PDF 7.5.0已发布。该版本支持转换PDF为透明背景的图片,修复了转换SVG到PDF内容不正确的问题,并且还修复了合并文档时出现的问题。详情请阅读以下内容。
新功能:
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("input.pdf");
doc.ConvertOptions.SetPdfToImageOptions(0);
Image image = doc.SaveAsImage(0);
image.Save("output.png", ImageFormat.Png);
问题修复:
Spire.Office 6.4.4已发布。本次版本更新带来了一些优质功能,比如:Spire.PDF支持了在转换PDF到Excel时设置根据线条决定单元格的功能,新增了PrintSettings.IsValid属性的功能以判断打印机是否可以使用;Spire.XLS支持获取打印机自定义的纸张大小后设置给工作表;Spire.Presentation支持通过流添加Video以及支持了添加自定义路径动画。除此之外,该版本还修复了大量问题。详情请阅读以下内容。
该版本涵盖了最新版的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
新功能:
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(PDFFile);
pdf.ConvertOptions.SetPdfToXlsxOptions(PdfToXlsxLayout.Line);
pdf.SaveToFile(ExcelFile, FileFormat.XLSX);
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
pdf.PrintSettings.PrinterName = @"Microsoft XPS Document Writer";
bool value = pdf.PrintSettings.IsValid;
问题修复:
问题修复:
问题修复:
新功能:
PageSetup.CustomPaperSizeName
问题修复:
新功能:
AppendVideoMedia(Stream stream, RectangleF rectangle);
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(0, 0, 200, 200));
AnimationEffect effect = ppt.Slides[0].Timeline.MainSequence.
AddEffect(shape, AnimationEffectType.PathUser);
CommonBehaviorCollection common = effect.CommonBehaviorCollection;
AnimationMotion motion = (AnimationMotion)common[0];
motion.Origin = AnimationMotionOrigin.Layout;
motion.PathEditMode = AnimationMotionPathEditMode.Relative;
MotionPath moinPath = new MotionPath();
moinPath.Add(MotionCommandPathType.MoveTo, new PointF[] { new PointF(0, 0) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.1f, 0.1f) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(-0.1f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.End, new PointF[] { }, MotionPathPointsType.CurveStraight, true);
motion.Path = moinPath;
ppt.SaveToFile(outputFile, FileFormat.Pptx2010);
ppt.Dispose();
问题修复:
Spire.Presentation 6.4.5已发布。该版本支持通过流添加Video以及支持了添加自定义路径动画。此外,本次更新还增强了转换PPT到图片的功能,同时也修复了加载PPT文档时出现的问题。详情请阅读以下内容。
新功能:
AppendVideoMedia(Stream stream, RectangleF rectangle);
Presentation ppt = new Presentation();
IAutoShape shape = ppt.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(0, 0, 200, 200));
AnimationEffect effect = ppt.Slides[0].Timeline.MainSequence.
AddEffect(shape, AnimationEffectType.PathUser);
CommonBehaviorCollection common = effect.CommonBehaviorCollection;
AnimationMotion motion = (AnimationMotion)common[0];
motion.Origin = AnimationMotionOrigin.Layout;
motion.PathEditMode = AnimationMotionPathEditMode.Relative;
MotionPath moinPath = new MotionPath();
moinPath.Add(MotionCommandPathType.MoveTo, new PointF[] { new PointF(0, 0) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(0.1f, 0.1f) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.LineTo, new PointF[] { new PointF(-0.1f, 0.2f) }, MotionPathPointsType.CurveAuto, true);
moinPath.Add(MotionCommandPathType.End, new PointF[] { }, MotionPathPointsType.CurveStraight, true);
motion.Path = moinPath;
ppt.SaveToFile(outputFile, FileFormat.Pptx2010);
ppt.Dispose();
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html
Spire.XLS 11.4.6已发布。本次更新的版本支持了获取打印机自定义的纸张大小后设置给工作表,增强了转换Excel到PDF的功能,并且修复了加载保存Excel文档等出现的问题。详情请阅读以下内容。
新功能:
PageSetup.CustomPaperSizeName
问题修复:
Spire.Spreadsheet 5.4.1已发布。本次更新修复了加载和显示Excel文档相关的问题。详情请阅读以下内容。
问题修复:
https://www.e-iceblue.cn/Downloads/Spire-Spreadsheet-NET.html
Spire.Doc 9.4.18已发布。该版本增强了转换Word到PDF/XPS的功能,并且还修复了加载HTML文档、添加HTML文本时出现的问题。详情请看以下内容。
问题修复:
Spire.Office for Java 4.4.6 已发布。本次版本更新带来了一系列新的功能,比如: Spire.XLS for Java支持添加删除数字签名并新增 setCustomPaperSize 方法以自定义纸张大小;Spire.PDF for Java查找换行文本时,支持返回所有的矩形区域信息并新增移除 JavaScript 脚本的方法;Spire.Presentation for Java支持表格的分布行和分布列的功能等等。此外,该版本还修复了大量问题。详情请阅读以下内容。
获取Spire.Office for Java 4.4.6请点击:https://www.e-iceblue.cn/Downloads/Spire-Office-JAVA.html
新功能:
Workbook workbook=new Workbook();
workbook.loadFromFile("C:/sample.xlsx");
CertificateAndPrivateKey cap = new CertificateAndPrivateKey("C:/Test1.pfx","e-iceblue");
workbook.addDigitalSignature(cap, "e-iceblue",new Date());
String result="C:/result.xlsx";
workbook.saveToFile(result,ExcelVersion.Version2013);
Workbook workbook2=new Workbook();
workbook2.loadFromFile(result);
workbook2.removeAllDigitalSignatures();
String result2="C:/result2.xlsx";
workbook2.saveToFile(result2,ExcelVersion.Version2013);
workbook.getWorksheets().get(0).getPageSetup().setCustomPaperSize(100, 100);
问题修复:
新功能:
PdfDocument doc = new PdfDocument(); doc.loadFromFile(inputFile);
FileWriter fileWriter = new FileWriter(outputFile, true);
int index=0;
for (PdfPageBase page : (Iterable) doc.getPages())
{
index++; PdfTextFind[] results = page.findText("findtext", EnumSet.of(TextFindParameter.CrossLine)).getFinds();
for (PdfTextFind text : results)
{
text.applyHighLight(); List bounds = text.getTextBounds();
String context="";
for (Rectangle2D rectangle2D:bounds)
{
context +="current "+index+" page;content:"+text.getSearchText()+ ";X:="+rectangle2D.getX()+","+"Y:="+rectangle2D.getY()+","+ "Width:="+rectangle2D.getWidth()+","+"height:="+rectangle2D.getHeight()+"\r\n";
} System.out.println(context); fileWriter.write(context); fileWriter.flush();
}
} fileWriter.close(); doc.saveToFile(outputPdf);
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile(input);
pdf.removeDocumentJavaScript();
pdf.saveToFile(output, FileFormat.PDF);
问题修复:
优化:
新功能:
ISlide slide = presentation.getSlides().get(0);
ITable table = (ITable) slide.getShapes().get(0);
table.distributeRows(0,3);
table.distributeColumns(0,2);
问题修复: