| | |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import com.ruoyi.manage.util.DocumentPreviewUtils; |
| | | |
| | | |
| | | import com.ruoyi.manage.mapper.*; |
| | |
| | | @Override |
| | | public void checkManageDocumentAlterPdf(Long id, HttpServletResponse response) throws Exception { |
| | | ManageDocumentAlter manageDocumentAlter = manageDocumentAlterMapper.selectById(id); |
| | | File file = new File(wordUrl + "/" + manageDocumentAlter.getAlterAfterUrl()); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | response.setContentType("application/pdf"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-disposition", "inline;filename=" + file.getName()); |
| | | response.setContentLength((int)file.length()); |
| | | OutputStream os = response.getOutputStream(); |
| | | // 将文件内容写入输出流 |
| | | byte[] buffer = new byte[4096]; |
| | | int bytesRead; |
| | | while ((bytesRead = fileInputStream.read(buffer)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | if (manageDocumentAlter == null || ObjectUtils.isEmpty(manageDocumentAlter.getAlterAfterUrl())) { |
| | | throw new ErrorException("文件未上传"); |
| | | } |
| | | os.flush(); |
| | | os.close(); |
| | | // PDF 直接输出,Word/图片在线转 PDF,供前端预览盖章 |
| | | DocumentPreviewUtils.writeAsPdf(new File(wordUrl + "/" + manageDocumentAlter.getAlterAfterUrl()), response); |
| | | } |
| | | |
| | | @Override |