• 大小: 40.81MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-08-04
  • 语言: Java
  • 标签:

资源简介

使用maven构建工具。前端使用pdf插件。后台搭建的springmvc框架,主要用于web在线预览pdf、word、excel文件。不需要安装office等其他插件

资源截图

代码片段和文件信息

package com.controller;

import com.util.Excel2Pdf;
import com.util.Word2Pdf;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * Created by wangyi on 2017/11/9.
 */
@Controller
@RequestMapping(“/review“)
public class ReviewController {

    @RequestMapping(“/word“)
    public void reviewWord(HttpServletRequest request HttpServletResponse response) throws Exception{
        response.setHeader(“content-disposition“ “attachment;filename=“ + URLEncoder.encode(“word“ “UTF-8“));
        String path = request.getServletContext().getRealPath(“/“);
        FileInputStream fis = new FileInputStream(path+“/resources/file/4894.docx“);
        OutputStream out = response.getOutputStream();
        Word2Pdf.word2pdf(fisout);
//        byte[] bs = new byte[1024];
//        int len = 0;
//        while ((len = fis.read(bs)) != -1) {
//            out.write(bs 0 len);
//        }
            out.close();
    }
    @RequestMapping(“/excel“)
    public void reviewExcel(HttpServletRequest request HttpServletResponse response) throws Exception{
        response.setHeader(“content-disposition“ “attachment;filename=“ + URLEncoder.encode(“excel“ “UTF-8“));
        String path = request.getServletContext().getRealPath(“/“);
        FileInputStream fis = new FileInputStream(path+“/resources/file/123.xlsx“);
        OutputStream out = response.getOutputStream();
        Excel2Pdf.excel2pdf(fisout);
//        byte[] bs = new byte[1024];
//        int len = 0;
//        while ((len = fis.read(bs)) != -1) {
//            out.write(bs 0 len);
//        }
        fis.close();
        out.close();
    }
    @RequestMapping(“/pdf“)
    public void reviewPdf(HttpServletRequest request HttpServletResponse response) throws IOException{
        response.setHeader(“content-disposition“ “attachment;filename=“ + URLEncoder.encode(“pdf“ “UTF-8“));
        String path = request.getServletContext().getRealPath(“/“);
        FileInputStream fis = new FileInputStream(path+“/resources/file/123.pdf“);
        OutputStream out = response.getOutputStream();
        byte[] bs = new byte[1024];
        int len = 0;
        while ((len = fis.read(bs)) != -1) {
            out.write(bs 0 len);
        }
        fis.close();
        out.close();
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        300  2017-11-09 20:10  pdfDemo\.idea\artifacts\pdfDemo_war.xml

     文件       2718  2017-11-13 09:44  pdfDemo\.idea\artifacts\pdfDemo_war_exploded.xml

     文件        626  2017-11-09 20:10  pdfDemo\.idea\compiler.xml

     文件        514  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__aopalliance_aopalliance_1_0.xml

     文件        536  2017-11-09 20:14  pdfDemo\.idea\libraries\Maven__aspose_aspose_license_14_9_0.xml

     文件        529  2017-11-13 09:44  pdfDemo\.idea\libraries\Maven__aspose_aspose_words_14_11_0.xml

     文件        466  2017-11-09 20:14  pdfDemo\.idea\libraries\Maven__aspose_cells_9_0_0.xml

     文件        605  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__commons_fileupload_commons_fileupload_1_2_1.xml

     文件        503  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__commons_io_commons_io_1_4.xml

     文件        572  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__commons_logging_commons_logging_1_1_1.xml

     文件        578  2017-11-09 20:31  pdfDemo\.idea\libraries\Maven__javax_servlet_javax_servlet_api_3_1_0.xml

     文件        437  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__jstl_jstl_1_2.xml

     文件        609  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_aop_3_2_4_RELEASE.xml

     文件        623  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_beans_3_2_4_RELEASE.xml

     文件        637  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_context_3_2_4_RELEASE.xml

     文件        616  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_core_3_2_4_RELEASE.xml

     文件        658  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_expression_3_2_4_RELEASE.xml

     文件        616  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_jdbc_3_2_4_RELEASE.xml

     文件        609  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_orm_3_2_4_RELEASE.xml

     文件        602  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_tx_3_2_4_RELEASE.xml

     文件        630  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_webmvc_3_2_4_RELEASE.xml

     文件        609  2017-11-09 20:17  pdfDemo\.idea\libraries\Maven__org_springframework_spring_web_3_2_4_RELEASE.xml

     文件        566  2017-11-09 22:08  pdfDemo\.idea\misc.xml

     文件        254  2017-11-09 20:09  pdfDemo\.idea\modules.xml

     文件      76502  2017-11-15 16:37  pdfDemo\.idea\workspace.xml

     文件    1016315  2016-12-18 00:18  pdfDemo\123.pdf

     文件        168  2017-11-09 20:13  pdfDemo\demo.html

     文件        584  2017-11-09 16:39  pdfDemo\license.xml

     文件       3178  2017-11-13 09:44  pdfDemo\pdfDemo.iml

     文件       4334  2017-11-13 10:02  pdfDemo\pom.xml

............此处省略1049个文件信息

评论

共有 条评论