提交 | 用户 | 时间
|
71e81e
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.modular.demos.controller; |
|
17 |
|
|
18 |
import cn.stylefeng.roses.core.base.controller.BaseController; |
|
19 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
20 |
import lombok.extern.slf4j.Slf4j; |
|
21 |
import org.springframework.core.io.ClassPathResource; |
|
22 |
import org.springframework.stereotype.Controller; |
|
23 |
import org.springframework.web.bind.annotation.GetMapping; |
|
24 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
25 |
import org.springframework.web.bind.annotation.RequestParam; |
|
26 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
27 |
|
|
28 |
/** |
|
29 |
* pdf预览 |
|
30 |
* |
|
31 |
* @author fengshuonan |
|
32 |
* @Date 2017年2月17日20:27:22 |
|
33 |
*/ |
|
34 |
@Controller |
|
35 |
@Slf4j |
|
36 |
public class PdfPreviewController extends BaseController { |
|
37 |
|
|
38 |
private String PREFIX = "/demos/pdf/"; |
|
39 |
|
|
40 |
/** |
|
41 |
* pdf预览 |
|
42 |
*/ |
|
43 |
@RequestMapping("/pdf") |
|
44 |
public String pdf() { |
|
45 |
return PREFIX + "pdf.html"; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* 预览 |
|
50 |
*/ |
|
51 |
@GetMapping(value = "/loadPdfFile", produces = "application/pdf") |
|
52 |
@ResponseBody |
|
53 |
public ClassPathResource loadPdfFile(@RequestParam(value = "file", required = false) String file) { |
|
54 |
|
|
55 |
if (ToolUtil.isEmpty(file)) { |
|
56 |
file = "demo.pdf"; |
|
57 |
} |
|
58 |
|
|
59 |
try { |
|
60 |
return new ClassPathResource("assets/expand/pdf/demo/" + file); |
|
61 |
} catch (Exception e) { |
|
62 |
e.printStackTrace(); |
|
63 |
return null; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
} |