js pdf展示插件(pdfobject)
2017-11-08 19:29
501 查看
我的环境:
前端: thymeleaf 后台springmvc
前端代码:
引入相关包:
<script th:src="@{/assets/js/pdf/pdfobject.js}"></script>
html容器:
js调用:
控制层代码:
效果图如下:
前端: thymeleaf 后台springmvc
前端代码:
引入相关包:
<script th:src="@{/assets/js/pdf/pdfobject.js}"></script>
html容器:
<div id="pdfDiv" style="height:600px;width:1200px"> </div>
js调用:
window.onload = function (){ var mid=getUrlParam("mid"); var success = new PDFObject({ url: "http://localhost:9080/ymlib/administrator/manuscriptManagement/getPdf?mid="+mid}).embed("pdfDiv"); }
控制层代码:
@RequestMapping(value = "/getPdf", method = RequestMethod.GET) public ResponseEntity<InputStreamResource> getPdf(@RequestParam(value = "mid") String mid) { Manuscript manuscript=manuscriptRepository.findOne(mid); Query query = new Query(Criteria.where("_id").is(new ObjectId(manuscript.getFileId()))); GridFSDBFile file_check = gridFsOps.findOne(query); InputStream in = file_check.getInputStream(); return ResponseEntity.ok().contentLength(file_check.getLength()) .cacheControl(CacheControl.maxAge(3600, TimeUnit.SECONDS)).contentType(MediaType.valueOf("application/pdf")) .body(new InputStreamResource(in)); }
效果图如下:
相关文章推荐
- [转]PDF预览插件PDFObject.js
- Acrobat PDF的ActiveObject控件js方法SetView控制页面展示类型
- PDFObject.js、jquerymedia.js、pdf.js的对比
- pdf.js展示流文件
- pdfobject.js和pdf.js的详解
- 前端预览PDF:PDFObject、PDF.js
- 常用的JS插件介绍:5、fancybox——弹出图片展示
- JS插件开发 - GIS地图打点视图展示
- PDF.js 在线pdf阅读插件(禁止打印,下载,每页水印)
- 读取pdf文件在页面上展示(不需要插件)
- 通过tableExport.js插件来实现导出Excel/Pdf/txt/json等
- jq图片展示插件highslide.js简单dom
- js判断机子是否安装pdf插件
- 移动开发中用到的几款js插件之滑动展示(1)
- jsPDF生成pdf后在网页展示实例
- PDF网页展示--PDF.js
- jq图片展示插件highslide.js简单dom
- vue插件开发 使用pdf.js实现手机端在线预览pdf文档
- 浏览器查看pdf插件pdfobject
- PDF.js插件的使用--在线浏览PDF文件