기업회원 첨부파일 PDF뷰어 기능추가

This commit is contained in:
itn 2023-08-02 10:24:31 +09:00
parent c2dcb50663
commit edb70d1d90
6 changed files with 65 additions and 28 deletions

View File

@ -110,7 +110,7 @@ public final class PdfUtil {
File imgFiles = new File(imgDir + "." +extsn);
Image img = ImageIO.read(imgFiles);
PDPage page = new PDPage(PDRectangle.A2);
PDPage page = new PDPage(PDRectangle.A4);
doc.addPage(page);
PDImageXObject pdImage = PDImageXObject.createFromFile(imgFiles.toString(), doc);
@ -131,8 +131,8 @@ public final class PdfUtil {
PDPageContentStream contents = new PDPageContentStream(doc, page);
contents.drawImage(pdImage, pageWidthPosition, pageHeightPosition, imgWidth, imgHeight);
contents.close();
doc.save("/usr/local/tomcat/file/sht/pdf/" + uuid + ".pdf");
//doc.save("C:/TEST/" + uuid + ".pdf");
//doc.save("/usr/local/tomcat/file/sht/pdf/" + uuid + ".pdf");
doc.save("C:/TEST/" + uuid + ".pdf");
} catch (Exception e) {
System.out.println("Exception! : " + e.getMessage());

View File

@ -466,8 +466,8 @@ public class EgovFileDownloadController {
try {
File uFile = new File("/usr/local/tomcat/file/sht/pdf/", fileNm);
//File uFile = new File("C:/TEST/", fileNm);
//File uFile = new File("/usr/local/tomcat/file/sht/pdf/", fileNm);
File uFile = new File("C:/TEST/", fileNm);
long fSize = uFile.length();

View File

@ -5049,13 +5049,22 @@ public class MjonMsgController {
FileVO fvo = fileService.selectFileInf(fileVO);
String path = "";
String fileType = "";
String[] imgExtArray = {"bmp", "gif", "jpeg", "jpg", "png", "tif", "tiff", "psd", "rle"};
List<String> imgExtList = new ArrayList<>(Arrays.asList(imgExtArray));
if(fvo != null) {
if("pdf".equals(fvo.getFileExtsn())) {
path = "/cmm/fms/FileDown.do?atchFileId="+ fvo.getAtchFileId() + "&fileSn=" + fvo.getFileSn();
}else {
fileType = "pdf";
} else if(imgExtList.contains(fvo.getFileExtsn())) {
String storePath = fvo.getFileStreCours() + fvo.getStreFileNm();
path = "/cmm/fms/FileDowntest.do?fileNm="+ PdfUtil.makeImgPdf(storePath, fvo.getFileExtsn());
fileType = "img";
} else {
String storePath = fvo.getFileStreCours() + fvo.getStreFileNm();
path = "/cmm/fms/FileDowntest.do?fileNm="+ PdfUtil.makeImgPdf(storePath, fvo.getFileExtsn());
fileType = "etc";
}
}
@ -5066,6 +5075,8 @@ public class MjonMsgController {
String hstMbtlNum = request.getParameter("hstMbtlNum");
model.addAttribute("pdfPath", path);
model.addAttribute("fileType", fileType);
model.addAttribute("atchFileId", fileVO.getAtchFileId());
model.addAttribute("mberNm", mberNm);
model.addAttribute("bizNo", bizNo);
model.addAttribute("ceoNm", ceoNm);
@ -5080,17 +5091,27 @@ public class MjonMsgController {
FileVO fvo = fileService.selectFileInf(fileVO);
String path = "";
String fileType = "";
String[] imgExtArray = {"bmp", "gif", "jpeg", "jpg", "png", "tif", "tiff", "psd", "rle"};
List<String> imgExtList = new ArrayList<>(Arrays.asList(imgExtArray));
if(fvo != null) {
if("pdf".equals(fvo.getFileExtsn())) {
path = "/cmm/fms/FileDown.do?atchFileId="+ fvo.getAtchFileId() + "&fileSn=" + fvo.getFileSn();
}else {
fileType = "pdf";
} else if(imgExtList.contains(fvo.getFileExtsn())) {
String storePath = fvo.getFileStreCours() + fvo.getStreFileNm();
path = "/cmm/fms/FileDowntest.do?fileNm="+ PdfUtil.makeImgPdf(storePath, fvo.getFileExtsn());
fileType = "img";
} else {
String storePath = fvo.getFileStreCours() + fvo.getStreFileNm();
path = "/cmm/fms/FileDowntest.do?fileNm="+ PdfUtil.makeImgPdf(storePath, fvo.getFileExtsn());
fileType = "etc";
}
}
model.addAttribute("pdfPath", path);
model.addAttribute("fileType", fileType);
return "/uss/ion/msg/pdfView";
}

View File

@ -33,7 +33,7 @@
</script>
<c:forEach var="fileVO" items="${fileList}" varStatus="status">
<a href="javascript:fn_egov_downFile('<c:out value="${fileVO.atchFileId}"/>','<c:out value="${fileVO.fileSn}"/>')" class="fileName" title="다운로드"><img src="/publish/images/content/file_img2.png" alt="첨부파일"></a>
<a href="javascript:fn_egov_downFile('<c:out value="${fileVO.atchFileId}"/>','<c:out value="${fileVO.fileSn}"/>')" class="fileName" title="다운로드"><img src="/publish/images/content/file_img2.png" alt="첨부파일" style="vertical-align:middle;"></a>
</c:forEach>
<iframe width=0 height=0 name='hiddenframe' style='display:none;'></iframe>

View File

@ -30,9 +30,9 @@ function pdfViewPop(atchFileId,mberNm,bizNo,ceoNm,hstManagerNm,hstMbtlNum) {
document.pdfForm.hstManagerNm.value = hstManagerNm;
document.pdfForm.hstMbtlNum.value = hstMbtlNum;
document.pdfForm.fileSn.value = 0;
window.open("about:blank", 'taxListPopup', 'width=1020, height=800, top=100, left=0, fullscreen=no, menubar=no, status=no, toolbar=no, titlebar=no, location=no, scrollbars=yes');
window.open("about:blank", 'pdfPopup', 'width=1020, height=800, top=100, left=0, fullscreen=no, menubar=no, status=no, toolbar=no, titlebar=no, location=no, scrollbars=no');
document.pdfForm.action = "<c:url value='/uss/ion/msg/pdfView.do'/>";
document.pdfForm.target = "taxListPopup";
document.pdfForm.target = "pdfPopup";
document.pdfForm.submit();
}
@ -300,7 +300,7 @@ function fnSetCalMonth(val) {
</head>
<body>
<form name="pdfForm" action="<c:url value='/uss/ion/msg/pdfView.do'/>" method="post">
<form name="pdfForm" method="post">
<input type="hidden" name="atchFileId"/>
<input type="hidden" name="fileSn"/>
<input type="hidden" name="mberNm"/>
@ -478,29 +478,29 @@ function fnSetCalMonth(val) {
<td><c:out value="${result.hstMbtlNum}"/></td>
<td class="td_file" style="vertical-align:middle;">
<c:if test="${result.atchFileId ne '' || result.atchFileId ne null}">
<c:import url="/cmm/fms/selectAddrAgencyFileInfs.do" charEncoding="utf-8">
<c:import url="/cmm/fms/selectMberFileInfs.do" charEncoding="utf-8">
<c:param name="param_atchFileId" value="${result.atchFileId}" />
</c:import>
</c:if>
<%--
<!--/cmm/fms/selectAddrAgencyFileInfs.do-->
<!--/cmm/fms/selectMberFileInfs.do-->
<c:if test="${result.atchFileId ne '' && result.atchFileId ne null}">
<button class="btnType btnType20" onclick="pdfViewPop('${result.atchFileId}','${result.mberNm}','${result.bizNo}','${result.ceoNm}','${result.hstManagerNm}','${result.hstMbtlNum}')" style="height:20px !important; padding:0 2px !important;">V</button>
<button class="btnType btnType20" onclick="pdfViewPop('${result.atchFileId}','${result.mberNm}','${result.bizNo}','${result.ceoNm}','${result.hstManagerNm}','${result.hstMbtlNum}'); return false;" style="height:20px !important; padding:0 2px !important;">V</button>
</c:if>
--%>
</td>
<td class="td_file">
<c:if test="${result.workAtchFileId ne '' || result.workAtchFileId ne null}">
<c:import url="/cmm/fms/selectAddrAgencyFileInfs.do" charEncoding="utf-8">
<c:import url="/cmm/fms/selectMberFileInfs.do" charEncoding="utf-8">
<c:param name="param_atchFileId" value="${result.workAtchFileId}" />
</c:import>
</c:if>
<%--
<!--/cmm/fms/selectMberFileInfs.do-->
<c:if test="${result.workAtchFileId ne '' && result.workAtchFileId ne null}">
<button class="btnType btnType20" onclick="pdfViewPop('${result.workAtchFileId}','${result.mberNm}','${result.bizNo}','${result.ceoNm}','${result.hstManagerNm}','${result.hstMbtlNum}')" style="height:20px !important; padding:0 2px !important;">V</button>
<button class="btnType btnType20" onclick="pdfViewPop('${result.workAtchFileId}','${result.mberNm}','${result.bizNo}','${result.ceoNm}','${result.hstManagerNm}','${result.hstMbtlNum}'); return false;" style="height:20px !important; padding:0 2px !important;">V</button>
</c:if>
--%>
</td>
<td>
<c:forEach var="item" items="${hstTypeList}" varStatus="status">

View File

@ -26,13 +26,21 @@
<html lang="ko">
<head>
<link rel="stylesheet" href="/pb/css/reset.css">
<link rel="stylesheet" href="/pb/css/common.css">
<link rel="stylesheet" href="/pb/css/content.css?date=202301160001">
<link rel="stylesheet" href="/pb/css/popup.css">
<link rel="stylesheet" href="/pb/css/reset.css">
<link rel="stylesheet" href="/pb/css/common.css">
<link rel="stylesheet" href="/pb/css/content.css?date=202301160001">
<link rel="stylesheet" href="/pb/css/popup.css">
<script type="text/javascript" src="<c:url value='/js/EgovMultiFile.js'/>"></script>
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<script src="/pb/js/jquery-3.5.0.js"></script>
<script type="text/javascript" src="<c:url value='/js/EgovMultiFile.js'/>"></script>
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<style>
html {
overflow-x: hidden;
overflow-y: auto;
}
</style>
</head>
<body>
@ -67,7 +75,15 @@
</table>
</div>
<canvas id="the-canvas" name="the-canvas" style="max-width: 1000px; margin-top: 25px; margin-bottom: 25px;"></canvas>
<c:if test="${fileType eq 'etc'}">
<div style="width: 100%; text-align: center; margin: 30px 0 30px 0; color: red;">
PDF 뷰어에서 지원하지 않는 형식의 파일입니다. 첨부파일 다운로드후 확인해주세요. &nbsp;
<c:import url="/cmm/fms/selectMberFileInfs.do" charEncoding="utf-8">
<c:param name="param_atchFileId" value="${atchFileId}" />
</c:import>
</div>
</c:if>
<canvas id="the-canvas" name="the-canvas" style="min-width: 700px; max-width: 1000px; margin-top: 25px; margin-bottom: 25px;"></canvas>
<div>
<button class="btnType" id="prev">Previous</button>
@ -86,7 +102,7 @@
var pageNum = 1;
var pageRendering = false;
var pageNumPending = null;
var scale = 0.8;
var scale = 1.4;
var canvas = document.getElementById('the-canvas');
var ctx = canvas.getContext('2d');
/* var url = '/cmm/fms/FileDown.do?atchFileId=FILE_000000000019061&fileSn=0'; */