pdf샘플 출력 화면 보기 추가

main
이범준 12 months ago
parent 48a25b5ab8
commit 3739e01a54

@ -51,6 +51,7 @@ public class Advntce extends PDFFormat {
text("vltnArtcl","위반내용",""),
text("vltnLawNm","위반법령",""),
text("crdnSn","증거번호",""),
text("crdnSn","최초금액","ffnlgCrdnAmt"),
text("amt","금액",""),
text("untilYmd","납부기한",""),
@ -150,6 +151,9 @@ public class Advntce extends PDFFormat {
case "crdnSn" -> {
result = dataObject.string("CRDN_SN");
}
case "ffnlgCrdnAmt" -> {
result = dataObject.string("FFNLG_CRDN_AMT");
}
case "amt" -> {
result = CmmnUtil.addCommaToNumber(dataObject.string(""));
}
@ -280,10 +284,37 @@ public class Advntce extends PDFFormat {
@Override
public DataObject createSampleData() {
DataObject dataObject = new DataObject();
dataObject.put("rtpyrNm", "홍길동");
dataObject.put("rtpyrAddr", "무슨도 무슨시 무슨구");
dataObject.put("rtpyrDtlAddr", "ㅇㅇ아파트 999호");
dataObject.put("rtpyrZip", "12345");
dataObject.put("RTPYR_NM", "홍길동");
dataObject.put("RTPYR_ADDR", "무슨도 무슨시 무슨구");
dataObject.put("RTPYR_DTL_ADDR", "ㅇㅇ아파트 999호");
dataObject.put("RTPYR_FULL_ADDR", "무슨도 무슨시 무슨구 ㅇㅇ아파트 999호");
dataObject.put("RTPYR_ZIP", "12345");
dataObject.put("VHRNO", "00가0000");
dataObject.put("CRDN_YMD", "20231204");
dataObject.put("CRDN_YMD_TM", "20231204080808");
dataObject.put("CRDN_PLC", "사거리 건너편");
dataObject.put("FFNLG_CARMDL_NM", "승용");
dataObject.put("VLTN_ARTCL", "주차위반");
dataObject.put("VLTN_LAW_NM", "00법 제0조 제0항");
dataObject.put("CRDN_SN", "1234567890");
dataObject.put("VR_ACTNO", "000000-00-000000");
dataObject.put("VR_ACTNO1", "111111-00-000000");
dataObject.put("VR_ACTNO2", "222222-00-000000");
dataObject.put("VR_ACTNO3", "333333-00-000000");
dataObject.put("VR_ACTNO4", "444444-00-000000");
dataObject.put("VR_ACTNO5", "555555-00-000000");
dataObject.put("VR_ACTNO6", "666666-00-000000");
dataObject.put("VR_ACTNO7", "777777-00-000000");
dataObject.put("VR_ACTNO8", "888888-00-000000");
dataObject.put("VR_ACTNO9", "999999-00-000000");
dataObject.put("VR_ACTNO10", "101010-00-000000");
dataObject.put("EPAY_NO", "00000-0-00-00-000000000");
dataObject.put("FFNLG_CRDN_AMT", "100000");
dataObject.put("CRDN_PHOTO1", "");
dataObject.put("CRDN_PHOTO2", "");
dataObject.put("CRDN_PHOTO3", "");
dataObject.put("CRDN_PHOTO4", "");
return dataObject;
}

@ -271,9 +271,20 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
public Map<String, String> makePdfFile(String formatType, String formatName, PrintOption printOption, String[] crdnIds) {
Map<String, String> result = new HashMap<>();
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIDs(crdnIds);
List<DataObject> dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
PDFFormat pdfFormat = null;
if(formatName.equals("advntce")) {
pdfFormat = new Advntce();
}
List<DataObject> dataObjectList = new ArrayList<DataObject>();
if(crdnIds.length == 1 && crdnIds[0].equals("sample")) {
DataObject sample = pdfFormat.createSampleData();
dataObjectList.add(sample);
} else {
SprtQuery sprtQuery = new SprtQuery();
sprtQuery.setCrdnIDs(crdnIds);
dataObjectList = integrationSearchMapper.selectIntegrationDataList(sprtQuery);
}
DataObject userStngInfo = stngBean.getStng("user");
DataObject sggStngInfo = stngBean.getStng("sgg");
@ -331,10 +342,6 @@ public class Sprt01ServiceBean extends AbstractServiceBean implements Sprt01Serv
sndngSeCd = "02";
}
PDFFormat pdfFormat = null;
if(formatName.equals("advntce")) {
pdfFormat = new Advntce();
}
List<DefaultOtptStng> prototypeStngList = pdfFormat.getPrototypeStngs();
otptStngQuery.setSndngSeCd(sndngSeCd);

@ -30,6 +30,8 @@
</form>
</div>
<div class="float-end">
<input type="checkbox" id="viewSample--${pageName}" />
<label for="viewSample--${pageName}">저장 후 샘플 보기</label>
<button type="button" id="btnSave--${pageName}" class="btn btn-primary">저장</button>
</div>
</div>
@ -104,6 +106,8 @@
</div>
</div>
<span id="tempArea--${pageName}" hidden></span>
<template id="theadTr--${pageName}">
<tr>
<th style="width:40px"></th>
@ -551,8 +555,15 @@ $(document).ready(function(){
var rowArr2 = $P.getRowData("tbodyMultiple--${pageName}", query);
var rowArr = [...rowArr1, ...rowArr2];
for(var i=0; i<rowArr.length; i++){
if(rowArr[i].otptNm == ""){
alert("출력항목명을 선택하세요.");
return;
}
}
query.otptStngList = rowArr;
query = fnJsonToFormData(query,"otptStngList");
ajax.post({
@ -560,7 +571,9 @@ $(document).ready(function(){
data : query,
success : (resp) => {
if(resp.saved){
dialog.alert("저장되었습니다.");
if(!$("#viewSample--${pageName}").is(":checked")){
dialog.alert("저장되었습니다.");
}
$("#frmSearch--${pageName}").find("[name='sggCd']").val(query.sggCd);
$("#frmSearch--${pageName}").find("[name='taskSeCd']").val(query.taskSeCd);
@ -568,9 +581,48 @@ $(document).ready(function(){
$("#frmSearch--${pageName}").find("[name='otptPaperSeCd']").val(query.otptPaperSeCd);
$("#btnLoad--${pageName}").click();
if($("#viewSample--${pageName}").is(":checked")){
$P.fnMakeSampleFile();
}
}
}
});
}
$P.fnMakeSampleFile = () => {
var formFields = new FimsFormFields("#frmEdit--${pageName}");
var submitParam = formFields.get();
submitParam.crdnIds = "sample";
var url = "";
if(submitParam.sndngSeCd == "02"){
url = wctx.url("/sprt/sprt01/140/makeAdvntcePdf.do");
}
if(url == ""){
return;
}
ajax.post({
url : url,
data : submitParam,
success : (resp) => {
if(resp.filePath != null && resp.filePath != ""){
var samplePath = resp.filePath;
samplePath = samplePath.replaceAll("\\","%5c");
window.open(
wctx.url("/resources/html/pdf.html"+"?"+"path="+samplePath)
,"pdf_sample"
,'top=10, left=10'
);
}
}
});
}
$("#theadUnique--${pageName}").html($("#theadTr--${pageName}")[0].innerHTML);

@ -0,0 +1,72 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="/resources/image/favicon.ico" />
<!-- Fonts -->
<link rel="stylesheet" href="/resources/font/publicsans/fontface.css" />
<!-- Icons. Uncomment required icon fonts -->
<link rel="stylesheet" href="/resources/3rd-party/sneat/fonts/boxicons.css" />
<link rel="stylesheet" href="/resources/3rd-party/sneat/fonts/fontawesome.css" />
<link rel="stylesheet" href="/resources/3rd-party/sneat/fonts/flag-icons.css" />
<link rel="stylesheet" href="/resources/css/fims/framework/common/xit-icon.css" />
<!-- Core CSS -->
<link rel="stylesheet" href="/resources/css/fims/framework/common/xit-core.css" />
<link rel="stylesheet" href="/resources/3rd-party/sneat/css/theme-default.css" />
<link rel="stylesheet" href="/resources/3rd-party/sneat/css/docs.css" />
<link rel="stylesheet" href="/resources/css/fims/framework/common/xit-core-extend.css" />
<!-- Vendors CSS -->
<link rel="stylesheet" href="/resources/3rd-party/sneat/libs/perfect-scrollbar/perfect-scrollbar.css" />
<link rel="stylesheet" href="/resources/css/styles.css" />
<link rel="stylesheet" href="/resources/css/fims/framework/common/common.css"/>
<link rel="stylesheet" href="/resources/lib/fims/framework/jquery-ui/1.13.2/themes/redmond/jquery-ui.css" />
<link rel="stylesheet" href="/resources/lib/fims/framework/datepicker/datepicker.css" />
<title>샘플 보기</title>
</head>
<body>
<div id="example" style="height:950px;">
</div>
<script type="text/JavaScript" src="/resources/3rd-party/sneat/libs/jquery/jquery.js" ></script>
<script src="/resources/3rd-party/sneat/libs/popper/popper.js"></script>
<script src="/resources/3rd-party/sneat/js/bootstrap.js"></script>
<script src="/resources/3rd-party/sneat/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
<script src="/resources/3rd-party/sneat/libs/hammer/hammer.js"></script>
<script src="/resources/3rd-party/sneat/libs/i18n/i18n.js"></script>
<script src="/resources/3rd-party/sneat/js/menu.js"></script>
<script src="/resources/3rd-party/sneat/libs/jstree/jstree.js"></script>
<script src="/resources/3rd-party/jstree/jstree-support.js"></script>
<script src="/resources/3rd-party/sneat/libs/chartjs/chartjs.js"></script>
<script src="/resources/lib/fims/framework/jquery-ui/1.13.2/jquery-ui.js"></script>
<script src="/resources/js/base/base.js"></script>
<script src="/resources/js/base/base-fims.js"></script>
<script src="/resources/js/base/dataset.js"></script>
<script src="/resources/js/fims/framework/pdfobject.js"></script>
<script language="javascript">
var pdfPath = location.search.split("=")[1];
pdfPath = pdfPath.replaceAll("%5c","/");
var curPage = location.href;
var center = location.pathname;
var end = location.search;
var start = curPage.replace(center+end,"/");
PDFObject.embed(start+pdfPath, "#example");
</script>
</body>
</html>

@ -0,0 +1,341 @@
/**
* PDFObject v2.2.12
* https://github.com/pipwerks/PDFObject
* @license
* Copyright (c) 2008-2023 Philip Hutchison
* MIT-style license: http://pipwerks.mit-license.org/
* UMD module pattern from https://github.com/umdjs/umd/blob/master/templates/returnExports.js
*/
(function (root, factory) {
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === "object" && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.PDFObject = factory();
}
}(this, function () {
"use strict";
//PDFObject is designed for client-side (browsers), not server-side (node)
//Will choke on undefined navigator and window vars when run on server
//Return boolean false and exit function when running server-side
if( typeof window === "undefined" ||
window.navigator === undefined ||
window.navigator.userAgent === undefined ||
window.navigator.mimeTypes === undefined){
return false;
}
let pdfobjectversion = "2.2.12";
let nav = window.navigator;
let ua = window.navigator.userAgent;
//Time to jump through hoops -- browser vendors do not make it easy to detect PDF support.
/*
IE11 still uses ActiveX for Adobe Reader, but IE 11 doesn't expose window.ActiveXObject the same way
previous versions of IE did. window.ActiveXObject will evaluate to false in IE 11, but "ActiveXObject"
in window evaluates to true.
MS Edge does not support ActiveX so this test will evaluate false
*/
let isIE = ("ActiveXObject" in window);
/*
There is a coincidental correlation between implementation of window.promises and native PDF support in desktop browsers
We use this to assume if the browser supports promises it supports embedded PDFs
Is this fragile? Sort of. But browser vendors removed mimetype detection, so we're left to improvise
*/
let isModernBrowser = (window.Promise !== undefined);
//Older browsers still expose the mimeType
let supportsPdfMimeType = (nav.mimeTypes["application/pdf"] !== undefined);
//Safari on iPadOS doesn't report as 'mobile' when requesting desktop site, yet still fails to embed PDFs
let isSafariIOSDesktopMode = ( nav.platform !== undefined &&
nav.platform === "MacIntel" &&
nav.maxTouchPoints !== undefined &&
nav.maxTouchPoints > 1 );
//Quick test for mobile devices.
let isMobileDevice = (isSafariIOSDesktopMode || /Mobi|Tablet|Android|iPad|iPhone/.test(ua));
//Safari desktop requires special handling
let isSafariDesktop = ( !isMobileDevice &&
nav.vendor !== undefined &&
/Apple/.test(nav.vendor) &&
/Safari/.test(ua) );
//Firefox started shipping PDF.js in Firefox 19. If this is Firefox 19 or greater, assume PDF.js is available
let isFirefoxWithPDFJS = (!isMobileDevice && /irefox/.test(ua) && ua.split("rv:").length > 1) ? (parseInt(ua.split("rv:")[1].split(".")[0], 10) > 18) : false;
/* ----------------------------------------------------
Supporting functions
---------------------------------------------------- */
let createAXO = function (type){
var ax;
try {
ax = new ActiveXObject(type);
} catch (e) {
ax = null; //ensure ax remains null
}
return ax;
};
//If either ActiveX support for "AcroPDF.PDF" or "PDF.PdfCtrl" are found, return true
//Constructed as a method (not a prop) to avoid unneccesarry overhead -- will only be evaluated if needed
let supportsPdfActiveX = function (){ return !!(createAXO("AcroPDF.PDF") || createAXO("PDF.PdfCtrl")); };
//Determines whether PDF support is available
let supportsPDFs = (
//As of Sept 2020 no mobile browsers properly support PDF embeds
!isMobileDevice && (
//We're moving into the age of MIME-less browsers. They mostly all support PDF rendering without plugins.
isModernBrowser ||
//Modern versions of Firefox come bundled with PDFJS
isFirefoxWithPDFJS ||
//Browsers that still support the original MIME type check
supportsPdfMimeType ||
//Pity the poor souls still using IE
(isIE && supportsPdfActiveX())
)
);
//Create a fragment identifier for using PDF Open parameters when embedding PDF
let buildURLFragmentString = function(pdfParams){
let string = "";
let prop;
if(pdfParams){
for (prop in pdfParams) {
if (pdfParams.hasOwnProperty(prop)) {
string += encodeURIComponent(prop) + "=" + encodeURIComponent(pdfParams[prop]) + "&";
}
}
//The string will be empty if no PDF Params found
if(string){
string = "#" + string;
//Remove last ampersand
string = string.slice(0, string.length - 1);
}
}
return string;
};
let embedError = function (msg, suppressConsole){
if(!suppressConsole){
console.log("[PDFObject] " + msg);
}
return false;
};
let emptyNodeContents = function (node){
while(node.firstChild){
node.removeChild(node.firstChild);
}
};
let getTargetElement = function (targetSelector){
//Default to body for full-browser PDF
let targetNode = document.body;
//If a targetSelector is specified, check to see whether
//it's passing a selector, jQuery object, or an HTML element
if(typeof targetSelector === "string"){
//Is CSS selector
targetNode = document.querySelector(targetSelector);
} else if (window.jQuery !== undefined && targetSelector instanceof jQuery && targetSelector.length) {
//Is jQuery element. Extract HTML node
targetNode = targetSelector.get(0);
} else if (targetSelector.nodeType !== undefined && targetSelector.nodeType === 1){
//Is HTML element
targetNode = targetSelector;
}
return targetNode;
};
let generatePDFObjectMarkup = function (embedType, targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL){
//Ensure target element is empty first
emptyNodeContents(targetNode);
let source = url;
if(embedType === "pdfjs"){
//If PDFJS_URL already contains a ?, assume querystring is in place, and use an ampersand to append PDFJS's file parameter
let connector = (PDFJS_URL.indexOf("?") !== -1) ? "&" : "?";
source = PDFJS_URL + connector + "file=" + encodeURIComponent(url) + pdfOpenFragment;
} else {
source += pdfOpenFragment;
}
let el_type = (embedType === "pdfjs" || embedType === "iframe") ? "iframe" : "embed";
let el = document.createElement(el_type);
el.className = "pdfobject";
el.type = "application/pdf";
el.title = title;
el.src = source;
if(id){
el.id = id;
}
if(el_type === "iframe"){
el.allow = "fullscreen";
el.frameborder = "0";
}
if(!omitInlineStyles){
let style = (el_type === "embed") ? "overflow: auto;" : "border: none;";
if(targetNode !== document.body){
//assign width and height to target node
style += "width: " + width + "; height: " + height + ";";
} else {
//this is a full-page embed, use CSS to fill the viewport
style += "position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;";
}
el.style.cssText = style;
}
//Allow developer to insert custom attribute on embed/iframe element, but ensure it does not conflict with attributes used by PDFObject
let reservedTokens = ["className", "type", "title", "src", "style", "id", "allow", "frameborder"];
if(customAttribute && customAttribute.key && reservedTokens.indexOf(customAttribute.key) === -1){
el.setAttribute(customAttribute.key, (typeof customAttribute.value !== "undefined") ? customAttribute.value : "");
}
targetNode.classList.add("pdfobject-container");
targetNode.appendChild(el);
return targetNode.getElementsByTagName(el_type)[0];
};
let embed = function(url, targetSelector, options){
//If targetSelector is not defined, convert to boolean
let selector = targetSelector || false;
//Ensure options object is not undefined -- enables easier error checking below
let opt = options || {};
//Get passed options, or set reasonable defaults
let id = (typeof opt.id === "string") ? opt.id : "";
let page = opt.page || false;
let pdfOpenParams = opt.pdfOpenParams || {};
let fallbackLink = (typeof opt.fallbackLink === "string" || typeof opt.fallbackLink === "boolean") ? opt.fallbackLink : true;
let width = opt.width || "100%";
let height = opt.height || "100%";
let title = opt.title || "Embedded PDF";
let assumptionMode = (typeof opt.assumptionMode === "boolean") ? opt.assumptionMode : true;
let forcePDFJS = (typeof opt.forcePDFJS === "boolean") ? opt.forcePDFJS : false;
let supportRedirect = (typeof opt.supportRedirect === "boolean") ? opt.supportRedirect : false;
let omitInlineStyles = (typeof opt.omitInlineStyles === "boolean") ? opt.omitInlineStyles : false;
let suppressConsole = (typeof opt.suppressConsole === "boolean") ? opt.suppressConsole : false;
let forceIframe = (typeof opt.forceIframe === "boolean") ? opt.forceIframe : false;
let PDFJS_URL = opt.PDFJS_URL || false;
let targetNode = getTargetElement(selector);
let fallbackHTML = "";
let pdfOpenFragment = "";
let customAttribute = opt.customAttribute || {};
let fallbackHTML_default = "<p>This browser does not support inline PDFs. Please download the PDF to view it: <a href='[url]'>Download PDF</a></p>";
//Ensure URL is available. If not, exit now.
if(typeof url !== "string"){ return embedError("URL is not valid", suppressConsole); }
//If target element is specified but is not valid, exit without doing anything
if(!targetNode){ return embedError("Target element cannot be determined", suppressConsole); }
//page option overrides pdfOpenParams, if found
if(page){ pdfOpenParams.page = page; }
//Stringify optional Adobe params for opening document (as fragment identifier)
pdfOpenFragment = buildURLFragmentString(pdfOpenParams);
// --== Do the dance: Embed attempt #1 ==--
//If the forcePDFJS option is invoked, skip everything else and embed as directed
if(forcePDFJS && PDFJS_URL){
return generatePDFObjectMarkup("pdfjs", targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL);
}
// --== Embed attempt #2 ==--
//Embed PDF if traditional support is provided, or if this developer is willing to roll with assumption
//that modern desktop (not mobile) browsers natively support PDFs
if(supportsPDFs || (assumptionMode && !isMobileDevice)){
//Should we use <embed> or <iframe>? In most cases <embed>.
//Allow developer to force <iframe>, if desired
//There is an edge case where Safari does not respect 302 redirect requests for PDF files when using <embed> element.
//Redirect appears to work fine when using <iframe> instead of <embed> (Addresses issue #210)
//Forcing Safari desktop to use iframe due to freezing bug in macOS 11 (Big Sur)
let embedtype = (forceIframe || supportRedirect || isSafariDesktop) ? "iframe" : "embed";
return generatePDFObjectMarkup(embedtype, targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute);
}
// --== Embed attempt #3 ==--
//If everything else has failed and a PDFJS fallback is provided, try to use it
if(PDFJS_URL){
return generatePDFObjectMarkup("pdfjs", targetNode, url, pdfOpenFragment, width, height, id, title, omitInlineStyles, customAttribute, PDFJS_URL);
}
// --== PDF embed not supported! Use fallback ==--
//Display the fallback link if available
if(fallbackLink){
fallbackHTML = (typeof fallbackLink === "string") ? fallbackLink : fallbackHTML_default;
targetNode.innerHTML = fallbackHTML.replace(/\[url\]/g, url);
}
return embedError("This browser does not support embedded PDFs", suppressConsole);
};
return {
embed: function (a,b,c){ return embed(a,b,c); },
pdfobjectversion: (function () { return pdfobjectversion; })(),
supportsPDFs: (function (){ return supportsPDFs; })()
};
}));
Loading…
Cancel
Save