Aspose實現Office轉PDF (ASP.NET)


0.添加Aspose的DLL


1.可以直接去官網下載,不過默認是帶水印的,如需去除水印可以購買

2.當然也可以在國內的一些下載站下載

3.將Aspose.Cells.dll、Aspose.Words.dll 兩個文件添加到項目的bin目錄下

4.給大家提供一個學習用地址:http://www.dxper.net/thread-4028-1-1.html

PS:ppt轉pdf用.net2.0文件夾下的Aspose.Slides.dll即可

1.Word轉PDF


1. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Words;
using Aspose.Words.Saving;
using System.IO;
using System.Drawing;
using System.Text;
using Aspose.Cells;
public partial class Word2PDF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Document doc = new Document(@"C:\Users\DUANCHENGHUA\Desktop\質量月PPT\2015年質量月活動方案 - 副本.doc");
        doc.Save(@"C:\Users\DUANCHENGHUA\Desktop\2015年質量月活動方案 - 副本.pdf", Aspose.Words.SaveFormat.Pdf);
            
    }
}

 

2.Excel轉PDF、PPT轉PDF


1.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aspose.Words;
using Aspose.Words.Saving;
using System.IO;
using System.Drawing;
using System.Text;
using Aspose.Cells;//Excel
using Aspose.Slides;//PPT
public partial class Word2PDF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Excel
        Workbook excel = new Workbook(@"C:\Users\DUANCHENGHUA\Desktop\數據庫信息表.xlsx");
        excel.Save(@"C:\Users\DUANCHENGHUA\Desktop\數據庫信息表.pdf", Aspose.Cells.SaveFormat.Pdf);
        //PPT
        Presentation ppt = new Presentation(@"C:\Users\DUANCHENGHUA\Desktop\2015年質量月活動1509.ppt");
        ppt.Save(@"C:\Users\DUANCHENGHUA\Desktop\2015年質量月活動1509.pdf", Aspose.Slides.Export.SaveFormat.Pdf);
        //PPTX
        Aspose.Slides.Pptx.PresentationEx pptx = new Aspose.Slides.Pptx.PresentationEx(@"C:\Users\DUANCHENGHUA\Desktop\演示文稿1.pptx");
        pptx.Save(@"C:\Users\DUANCHENGHUA\Desktop\演示文稿1.pdf", Aspose.Slides.Export.SaveFormat.Pdf);
            
    }
}

 




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM