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

Spire.Cloud 纯前端文档控件

Spire.Presentation for Java 3.5.4已发布。该版本新增了支持在形状中获取文本输入区域的最大宽度,以及获取形状中文本输入区域的宽度最大时文本的起始坐标等功能。此外,也成功修复了在将PPTX文档转换成图片、获取表格单元格中文本颜色、加载文件以及设置数据表格边框时出现的一些问题。新功能及问题修复详情见下文。

新功能:

问题修复:


获取Spire.Presentation for Java 3.5.4,请点击:

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);
    }
}

Java 隐藏图表的网格线

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。

版本信息如下:

获取Spire.Office 5.5.1, 请点击:

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


Spire.PDF

新功能:

问题修复:


Spire.Doc

新功能:

问题修复:


Spire.XLS

新功能:

问题修复:

Spire.XLS 10.5.7已发布。该版本添加了新功能支持转换HTML到Excel,同时也修复了一些在转换Excel到PDF、HTML以及转换XML到Excel时出现的问题。

新功能:

问题修复:


下载Spire.XLS 10.5.7,请点击:

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

PDF文件包(Portfolio)允许用户将多种不同类型的文件如Word、Excel、PDF、PowerPoint和图片等集合到一个PDF文件中,用户可以打开、更改PDF文件包中的单个文件,而不影响其他文件。本文将介绍如何使用Spire.PDF for .NET创建PDF文件包。

在创建PDF文件包时,Spire.PDF for .NET支持给包添加文件和文件夹。以下示例展示了如何使用Spire.PDF for .NET创建PDF文件包并添加文件。

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

C#/VB.NET 创建PDF文件包(Portfolio)

以下示例展示了如何使用Spire.PDF for .NET创建PDF文件包并添加文件夹。

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

C#/VB.NET 创建PDF文件包(Portfolio)

Spire.Doc for Java 3.5.2已发布。该版本主要修复了在加载Word文档、更新Word目录域以及将HTML转为Word时出现的一些问题。详情如下。

问题修复:


获取Spire.Doc for Java 3.5.2,请点击:

https://www.e-iceblue.cn/Downloads/Spire-Doc-JAVA.html

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

设置结果:

Java 设置 PDF 文本倾斜、旋转字体倾斜

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

将SVG图片保存为PDF

源SVG图片如下:

C#/VB.NET 添加和转换 SVG 图片到 PDF

C#
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);  

        }
    }
}
VB.NET
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

效果图:

C#/VB.NET 添加和转换 SVG 图片到 PDF

添加SVG图片到PDF

将已有的SVG图片插入到PDF时,我们还可以设置SVG图片的位置和大小:

C#
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);   


        }
    }
}
VB.NET
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

效果图:

C#/VB.NET 添加和转换 SVG 图片到 PDF

Spire.PDF 6.5.9 现已正式发布。该版本支持创建PDF Portfolios,同时一些在显示、打印和验证PDF文档时出现的问题也得以成功解决。新功能及问题修复详情,请查阅以下内容。

新功能:

问题修复:


获取Spire.PDF 6.5.9,请点击:

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

在Excel中,我们可以选中含有批注的单元格,右键并点击“显示/隐藏批注”选项来更改该批注的显示状态。本文将介绍如何使用Spire.XLS for Java实现在Excel文档中隐藏或显示批注。

原Excel文档:

Java 在 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);
    }
}

结果文档:

Java 在 Excel 文档中隐藏或显示批注