zoukankan      html  css  js  c++  java
  • 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:UsersDUANCHENGHUADesktop质量月PPT2015年质量月活动方案 - 副本.doc");
            doc.Save(@"C:UsersDUANCHENGHUADesktop2015年质量月活动方案 - 副本.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:UsersDUANCHENGHUADesktop数据库信息表.xlsx");
            excel.Save(@"C:UsersDUANCHENGHUADesktop数据库信息表.pdf", Aspose.Cells.SaveFormat.Pdf);
            //PPT
            Presentation ppt = new Presentation(@"C:UsersDUANCHENGHUADesktop2015年质量月活动1509.ppt");
            ppt.Save(@"C:UsersDUANCHENGHUADesktop2015年质量月活动1509.pdf", Aspose.Slides.Export.SaveFormat.Pdf);
            //PPTX
            Aspose.Slides.Pptx.PresentationEx pptx = new Aspose.Slides.Pptx.PresentationEx(@"C:UsersDUANCHENGHUADesktop演示文稿1.pptx");
            pptx.Save(@"C:UsersDUANCHENGHUADesktop演示文稿1.pdf", Aspose.Slides.Export.SaveFormat.Pdf);
                
        }
    }



  • 相关阅读:
    STM32F103 rtthread工程构建
    Alios-Things的学习与使用(1)
    AM335X用RGB888连接LCD如何以16位色彩模式显示图片
    为什么要网页模块化?
    前端应该了解的颜色的寓意
    iOS 8安装教程图解
    windows8开发-关于wp7应用迁移到win8 metro风格
    短小强悍的JavaScript异步调用库
    Linux启动过程分析
    小技能——markdown
  • 原文地址:https://www.cnblogs.com/moonache/p/4991459.html
Copyright © 2011-2022 走看看