冰蓝科技
|
028-81705109
|
|
微信扫一扫
|

Spire.Cloud 纯前端文档控件

本文介绍如何使用Spire.PDF从URL地址中下载PDF文档。

C#
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);
        }
    }
}
VB.NET
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

C#/VB.NET 从 URL 地址下载 PDF 文档

之前我们介绍了如何插入和读取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);

    }
}

效果图:

Java Excel 添加图片批注

本文介绍如何使用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();
    }
}

设置结果:

Java 自定义 PPT 动画路径

Spire.PDF 7.5.0已发布。该版本支持转换PDF为透明背景的图片,修复了转换SVG到PDF内容不正确的问题,并且还修复了合并文档时出现的问题。详情请阅读以下内容。

新功能:

问题修复:


获取Spire.PDF 7.5.0请点击:

https://www.e-iceblue.cn/Downloads/Spire-PDF-NET.html

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。

问题修复:

获取Spire.Office 6.4.4请点击:

https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html


Spire.PDF

新功能:

问题修复:


Spire.Doc

问题修复:


Spire.Spreadsheet

问题修复:


Spire.XLS

新功能:

问题修复:


Spire.Presentation

新功能:

问题修复:

Spire.Presentation 6.4.5已发布。该版本支持通过流添加Video以及支持了添加自定义路径动画。此外,本次更新还增强了转换PPT到图片的功能,同时也修复了加载PPT文档时出现的问题。详情请阅读以下内容。

新功能:

问题修复:


获取Spire.Presentation 6.4.5请点击:

https://www.e-iceblue.cn/Downloads/Spire-Presentation-NET.html

Spire.XLS 11.4.6已发布。本次更新的版本支持了获取打印机自定义的纸张大小后设置给工作表,增强了转换Excel到PDF的功能,并且修复了加载保存Excel文档等出现的问题。详情请阅读以下内容。

新功能:

问题修复:


下载Spire.XLS 11.4.6请点击:

https://www.e-iceblue.cn/Downloads/Spire-XLS-NET.html

Spire.Spreadsheet 5.4.1已发布。本次更新修复了加载和显示Excel文档相关的问题。详情请阅读以下内容。

问题修复:


获取Spire.Spreadsheet 5.4.1请点击:

https://www.e-iceblue.cn/Downloads/Spire-Spreadsheet-NET.html

Spire.Doc 9.4.18已发布。该版本增强了转换Word到PDF/XPS的功能,并且还修复了加载HTML文档、添加HTML文本时出现的问题。详情请看以下内容。

问题修复:


获取Spire.Doc 9.4.18请点击:

https://www.e-iceblue.cn/Downloads/Spire-Doc-NET.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


Spire.XLS for Java

新功能:

问题修复:


Spire.PDF for Java

新功能:

问题修复:


Spire.Presentation for Java

优化:

新功能:

问题修复: