메뉴얼 파일 수정(화면비 변경, 목차 및 템플릿 추가, 버전 정보 추가)

main
이범준 8 months ago
parent 7e26442bbf
commit 97e26a8931

@ -28,6 +28,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -286,10 +287,19 @@ public class FileController extends cokr.xit.base.file.web.FileController {
String filePath = ("menual/메뉴얼.pptx"); String filePath = ("menual/메뉴얼.pptx");
ClassPathResource cps = new ClassPathResource(filePath); ClassPathResource cps = new ClassPathResource(filePath);
InputStream menualIS = cps.getInputStream(); String menualVersion = "";
try (XMLSlideShow slideShow = new XMLSlideShow(cps.getInputStream())) {
menualVersion = slideShow
.getProperties()
.getCoreProperties()
.getUnderlyingProperties()
.getVersionProperty()
.get();
}
InputStream menualIS = cps.getInputStream();
mav.addObject("file", menualIS); mav.addObject("file", menualIS);
mav.addObject("filename", "메뉴얼.pptx"); mav.addObject("filename", "과태료통합관리시스템_메뉴얼"+"("+"v"+menualVersion+")"+".pptx");
mav.addObject("contentType", "application/vnd.openxmlformats-officedocument.presentationml.presentation"); mav.addObject("contentType", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
mav.addObject("length", menualIS.available()); mav.addObject("length", menualIS.available());

@ -1,23 +1,33 @@
//메뉴얼 다운로드 //메뉴얼 다운로드
function fnMenualDownload(){ function fnMenualDownload(){
ajax.get({ var filenameInHeader = "";
url : wctx.url("/file/downloadMenual.do"),
data : { }, fetch(wctx.url("/file/downloadMenual.do"))
xhrFields:{ responseType: 'blob' }, .then((response) => {
success : (resp) => { var header = response.headers.get('Content-Disposition');
var fileName = "메뉴얼.pptx"; console.log(header);
var parts = header.split(';');
filenameInHeader = parts[1].split('=')[1];
if(filenameInHeader.startsWith("\"") && filenameInHeader.endsWith("\"")){
filenameInHeader = filenameInHeader.substring(1,filenameInHeader.length-1);
}
filenameInHeader = decodeURIComponent(filenameInHeader);
return response.blob();
})
.then((blob) => {
var URL = window.URL || window.webkitURL; var URL = window.URL || window.webkitURL;
var downloadUrl = URL.createObjectURL(resp); var downloadUrl = URL.createObjectURL(blob);
var a = document.createElement("a"); var a = document.createElement("a");
a.href = downloadUrl; a.href = downloadUrl;
a.download = fileName; a.download = filenameInHeader;
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
document.body.removeChild(a); document.body.removeChild(a);
}
}); });
} }
//현재 활성화된 최상위 탭 영역을 반환한다. //현재 활성화된 최상위 탭 영역을 반환한다.

Loading…
Cancel
Save