Spire.Doc如果快速转换Word为PDF文件

作者:ComponentCN   出处:控件中国网   2015-05-27 09:52:38   阅读:6

Spire.Doc是一款全方位的Word文档创建、浏览、编辑和转换控件,可以快速转换word为PDF,通过改产品您可以直接创建word文件或者通过本地word模板创建,并把创建好的word文件转换为PDF,所有这些操作,客户电脑上都不需要安装任何Microsoft Word组件

使用该产品转换Word为PDF仅需要简单的2步即可完成

1.下载Spire.Doc for .NET 试用版,安装并在项目里引用控件动态链接库
2. 使用控件提供的LoadFromFile()方法加载Word文件,并使用SaveToFile()方法保存为PDF

具体的代码如下:
[c#]
using System;
using Spire.Doc;
using Spire.Doc.Documents;

namespace DoctoPDF
{
    class toPDF
    {
        static void Main(string[] args)
        {
            //Load Document
            Document document = new Document();
            document.LoadFromFile(@"E:\work\documents\TestSample.docx");

            //Convert Word to PDF
            document.SaveToFile("toPDF.PDF", FileFormat.PDF);

            //Launch Document
            System.Diagnostics.Process.Start("toPDF.PDF");
        }
    }
}
[VB.NET]
Imports System
Imports Spire.Doc
Imports Spire.Doc.Documents

Namespace DoctoPDF
    Friend Class toPDF
        Shared Sub Main(ByVal args() As String)
            'Load Document
            Dim document As New Document()
            document.LoadFromFile("E:\work\documents\TestSample.docx")

            'Convert Word to PDF
            document.SaveToFile("toPDF.PDF", FileFormat.PDF)

            'Launch Document
            System.Diagnostics.Process.Start("toPDF.PDF")
        End Sub
    End Class
End Namespace

转换后的截图如下:
doc2PDF_2.png

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat