• 大小: 4.41MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-02
  • 语言: C#
  • 标签: ASP.NET  在线预览  

资源简介

ASP.NET 仿百度文库文档在线预览 支持格式.pdf,.doc,docx,xls,xlsx,.ppt,pptx

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.IO;

namespace PDFWebViewer
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender EventArgs e)
        {
        }

        protected void btn_upload_Click(object sender EventArgs e)
        {
            if (fp_upload.HasFile)//判断文件上传控件是否包含文件
            {
                try
                {
                    string filePath = fp_upload.FileName;//上载的文件的名称
                    //上载的文件的名称-去掉文件格式
                    string fileName = fp_upload.FileName.Substring(0 filePath.LastIndexOf(“.“));
                    string fileExtention = filePath.Substring(filePath.LastIndexOf(“.“) + 1);//上传文件的文件格式
                    string swfToolPath = ConfigurationManager.AppSettings[“swfToolPath“];//工具文件的绝对地址
                    swfToolPath = HttpContext.Current.Server.MapPath(swfToolPath);//工具文件的物理地址
                    string uploadPath = ConfigurationManager.AppSettings[“uploadPath“]; //上传文件夹的绝对地址
                    uploadPath = HttpContext.Current.Server.MapPath(uploadPath);//上传文件夹地址的物理地址
                    string onlyData = DateTime.Now.ToString(“yyyyMMddHHmmssfff“);//当前时间格式化字符串
                    string uploadFlieName = onlyData + “.“ + fileExtention; //保存的上传文件名
                    string uploadPDFName = onlyData + “.pdf“;//保存的pdf文件名
                    string uploadWSFName = onlyData + “.swf“;//保存的swf文件名
                    string uploadFliePath = uploadPath + uploadFlieName;
                    string uploadPDFPath = uploadPath + uploadPDFName;
                    string uploadWSFPath = uploadPath + uploadWSFName;


                    #region 文件上传
                    if (!Directory.Exists(uploadPath))
                    {
                        Directory.CreateDirectory(uploadPath);
                    }
                    fp_upload.SaveAs(uploadFliePath);//保存文件到服务器上
                    #endregion


                    bool bl = Convert(uploadFliePath fileExtention uploadPDFPath);

                    if (bl)
                    {
                        #region PDF文件转换为SWF文件
                        /*-t: 源文件路径,即待转换的pdf文件路径。
                     * -s: 设置参数这里我们设置为 flashversion=9 ,即可以转换为9 的版本
                     * -o: 输出文件的路径
                     * */
                        //文件路径包含到““内防止要转换的过程中,文件夹名字带有空格,导致失败
                        string cmdStr = “  -t  \““ + uploadPDFPath + “\“ -s flashversion=9 -o \““ + uploadWSFPath + “\““;
                        bool iss = PDFWebViewer.baseClass.YcTools.PdfToSwf(swfToolPath cmdStr);//执行文件转换
                        #endregion

                        if (iss)//转换成功则跳到文档预览页面
                        {
                            string path = ConfigurationManager.AppSettings[“uploadPath“].Substring(2) + uplo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-24 10:27  PDFWebViewer\
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\
     文件         926  2014-04-24 10:27  PDFWebViewer\PDFWebViewer.sln
     文件       28160  2014-04-24 17:21  PDFWebViewer\PDFWebViewer.suo
     目录           0  2014-04-24 15:44  PDFWebViewer\PDFWebViewer\baseClass\
     文件        7349  2014-04-24 16:00  PDFWebViewer\PDFWebViewer\baseClass\ConvertToPDF.cs
     文件         873  2014-04-24 15:44  PDFWebViewer\PDFWebViewer\baseClass\YcTools.cs
     目录           0  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\bin\
     文件       10240  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\bin\PDFWebViewer.dll
     文件       24064  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\bin\PDFWebViewer.pdb
     文件         809  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\Index.aspx
     文件        5209  2014-04-24 16:22  PDFWebViewer\PDFWebViewer\Index.aspx.cs
     文件        1499  2014-04-24 12:01  PDFWebViewer\PDFWebViewer\Index.aspx.designer.cs
     目录           0  2014-04-24 10:27  PDFWebViewer\PDFWebViewer\obj\
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\
     文件        7931  2014-04-24 17:16  PDFWebViewer\PDFWebViewer\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\bin\
     文件       10240  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\bin\PDFWebViewer.dll
     文件       24064  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\bin\PDFWebViewer.pdb
     文件         809  2014-04-24 16:30  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Index.aspx
     文件        2500  2014-04-24 16:34  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\PDFViewer.aspx
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\
     文件      406496  2014-04-24 10:28  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\FlexPaperViewer.swf
     目录           0  2014-04-24 17:08  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\js\
     文件       10354  2014-04-24 10:28  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\js\flexpaper_flash.js
     文件       11332  2014-04-24 10:28  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\js\flexpaper_flash_debug.js
     文件       91342  2014-04-24 10:28  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\js\jquery.js
     文件         657  2014-04-24 10:28  PDFWebViewer\PDFWebViewer\obj\Debug\Package\PackageTmp\Plugins\FlexPaper\playerProductInstall.swf
............此处省略37个文件信息

评论

共有 条评论