|
|
|
|
@ -10,6 +10,7 @@ import java.util.Comparator;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
import org.apache.pdfbox.pdmodel.common.PDRectangle;
|
|
|
|
|
import org.apache.pdfbox.pdmodel.font.PDType0Font;
|
|
|
|
|
@ -61,10 +62,10 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
this.otptBscStng = otptBscStng;
|
|
|
|
|
this.otptArtclStngList = otptArtclStngList;
|
|
|
|
|
this.paperSeCd = paperSeCd;
|
|
|
|
|
if (paperSeCd.equals("01")) {
|
|
|
|
|
this.paperMilimeter = new float[] {210.0f , 297.0f};
|
|
|
|
|
} else if (paperSeCd.equals("02")){
|
|
|
|
|
this.paperMilimeter = new float[] {216.0f , 279.0f};
|
|
|
|
|
switch (paperSeCd) {
|
|
|
|
|
case "01": this.paperMilimeter = new float[] {210.0f , 297.0f}; break;
|
|
|
|
|
case "02": this.paperMilimeter = new float[] {216.0f , 279.0f}; break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -136,9 +137,9 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
* 포맷원형에 우편물 출력요소를 추가한다.
|
|
|
|
|
*/
|
|
|
|
|
public void addForPost(DefaultOtptArtclStng... prototypeStngs){
|
|
|
|
|
for (DefaultOtptArtclStng prototypeStng : prototypeStngs) {
|
|
|
|
|
this.prototypeStngs.add(prototypeStng.post());
|
|
|
|
|
}
|
|
|
|
|
this.prototypeStngs.addAll(Stream.of(prototypeStngs)
|
|
|
|
|
.map(setting -> setting.post()).toList()
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -214,7 +215,6 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
Map<String, PDType0Font> fontMap = getFontMap(writer = new PDFWriter());
|
|
|
|
|
//용지 크기 설정
|
|
|
|
|
writer.paper("01".equals(this.paperSeCd) ? "A4" : "LETTER");
|
|
|
|
|
|
|
|
|
|
List<DefaultOtptArtclStng> prototypeStngList = getPrototypeStngs();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -236,7 +236,6 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
.sorted(comparator1.thenComparing(comparator2))
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//대표단속사진 설정 여부 확인
|
|
|
|
|
boolean rprsCrdnPhotoYn = otptArtclStngList.stream()
|
|
|
|
|
.filter(item -> item.string("OTPT_ARTCL_NM").equals("rprsCrdnPhoto"))
|
|
|
|
|
@ -267,7 +266,8 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
boolean forPost = prototypeStng.isForPost();
|
|
|
|
|
String defaultValue = prototypeStng.getOtptBscVl();
|
|
|
|
|
|
|
|
|
|
if (prototypeStng.getComponentType().equals("text")) {
|
|
|
|
|
String componentType = prototypeStng.getComponentType();
|
|
|
|
|
if ("text".equals(componentType)) {
|
|
|
|
|
String align = this.getAlign(prototypeStng, otptArtclStng);
|
|
|
|
|
String lineChgYn = this.getLineChgYn(prototypeStng, otptArtclStng);
|
|
|
|
|
PDType0Font font = this.getFontType(prototypeStng, otptArtclStng, fontMap);
|
|
|
|
|
@ -280,7 +280,7 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
this.writeText(writer, textValue, pstn, size[0], align, lineChgYn
|
|
|
|
|
, font, fontSz, fontStyle, fontColr);
|
|
|
|
|
|
|
|
|
|
} else if (prototypeStng.getComponentType().equals("image")) {
|
|
|
|
|
} else if ("image".equals(componentType)) {
|
|
|
|
|
|
|
|
|
|
String imagePath = this.getMappingValue(otptArtclNm,defaultValue,forPost,dataObject,printOption,this.print);
|
|
|
|
|
|
|
|
|
|
@ -294,15 +294,12 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
|
|
|
|
|
File imageFile = new File(imagePath);
|
|
|
|
|
if (!imageFile.exists()) {
|
|
|
|
|
if (otptArtclNm.equals("offcs")) {
|
|
|
|
|
if (otptArtclNm.equals("offcs"))
|
|
|
|
|
throw new HttpStatusCodeException(500, "{\"failed\":true,\"description\":\"직인 파일을 찾을 수 없습니다.\"}", true);
|
|
|
|
|
}
|
|
|
|
|
if (otptArtclNm.equals("background")) {
|
|
|
|
|
if (otptArtclNm.equals("background"))
|
|
|
|
|
throw new HttpStatusCodeException(500, "{\"failed\":true,\"description\":\"배경이미지 파일을 찾을 수 없습니다.\"}", true);
|
|
|
|
|
}
|
|
|
|
|
if (otptArtclNm.equals("postSenderLogo")) {
|
|
|
|
|
if (otptArtclNm.equals("postSenderLogo"))
|
|
|
|
|
throw new HttpStatusCodeException(500, "{\"failed\":true,\"description\":\"우편물 송신자 로고 파일을 찾을 수 없습니다.\"}", true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
@ -339,7 +336,7 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (prototypeStng.getComponentType().equals("images")) {
|
|
|
|
|
} else if ("images".equals(componentType)) {
|
|
|
|
|
|
|
|
|
|
List<String> imagePaths = this.getMappingValues(otptArtclNm,defaultValue,forPost,dataObject,printOption,this.print);
|
|
|
|
|
|
|
|
|
|
@ -417,23 +414,20 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
}//출력항목 loop 끝
|
|
|
|
|
|
|
|
|
|
if (!completeFoldLine) {
|
|
|
|
|
if (!otptBscStng.string("FOLD_LINE_PSTN_SE_CD").equals("")) {
|
|
|
|
|
if (!isEmpty(otptBscStng.string("FOLD_LINE_PSTN_SE_CD"))) {
|
|
|
|
|
this.renderFoldLine(writer, otptBscStng.string("FOLD_LINE_PSTN_SE_CD"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
writer.endPage();
|
|
|
|
|
|
|
|
|
|
} //출력자료건수 loop 끝
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String downloadFileName = this.print.getFormatKorName()+"_"+this.print.getPrintRequestDt()+".pdf";
|
|
|
|
|
result.put("download", writer.getDownloadable().setFilename(downloadFileName));
|
|
|
|
|
result.put("downloadData", data);
|
|
|
|
|
result.put("dataNames", this.filterDownloadDataNames());
|
|
|
|
|
|
|
|
|
|
} catch(FileNotFoundException e) {
|
|
|
|
|
|
|
|
|
|
throw new RuntimeException("파일을 찾을 수 없습니다.");
|
|
|
|
|
} catch(HttpStatusCodeException e) {
|
|
|
|
|
throw e;
|
|
|
|
|
@ -444,8 +438,6 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* mm단위로 입력된 값을 pdf좌표계 형식으로 변환한다.
|
|
|
|
|
*/
|
|
|
|
|
@ -468,19 +460,14 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
float[] XYmm, float textAreaWidth_mm, String align, String newLineYn,
|
|
|
|
|
PDType0Font font, int fontSize, RenderingMode fontStyle, PDColor fontColor) {
|
|
|
|
|
try {
|
|
|
|
|
if (allText == null) {
|
|
|
|
|
if (allText == null)
|
|
|
|
|
allText = "";
|
|
|
|
|
}
|
|
|
|
|
if (newLineYn == null || newLineYn.equals("")) {
|
|
|
|
|
if (isEmpty(newLineYn))
|
|
|
|
|
newLineYn = "N";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float[] xyAbsolute = this.toPDFCoordinate(XYmm).absolute();
|
|
|
|
|
|
|
|
|
|
float textAreaWidth_pt = CmmnUtil.mmToPt(textAreaWidth_mm);
|
|
|
|
|
|
|
|
|
|
float allTextWidth = calcTextWidth(font, fontSize, allText);
|
|
|
|
|
|
|
|
|
|
String textArr[];
|
|
|
|
|
if (allText.equals("") || allText.length() == 1 || textAreaWidth_pt == 0
|
|
|
|
|
|| (allTextWidth <= textAreaWidth_pt)
|
|
|
|
|
@ -699,9 +686,8 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PstnAndSize[][] mergeLastImageCell(PstnAndSize[][] d2, String mergeDirection) {
|
|
|
|
|
if (!mergeDirection.equals("up") && !mergeDirection.equals("left")) {
|
|
|
|
|
if (!"up".equals(mergeDirection) && !"left".equals(mergeDirection))
|
|
|
|
|
throw new RuntimeException("PDF 파일 출력 중 오류가 발생하였습니다.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int xLengthOfD2 = d2.length;
|
|
|
|
|
int yLengthOfD2 = d2[0].length;
|
|
|
|
|
@ -782,10 +768,10 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float[] getPstnStng(DefaultOtptArtclStng prototypeStng, DataObject sggStng, String paperSeCd) {
|
|
|
|
|
if (!sggStng.string("LEFT_PSTN").equals("") && !sggStng.string("TOP_PSTN").equals("")) {
|
|
|
|
|
if (!isEmpty(sggStng.get("LEFT_PSTN")) && !isEmpty(sggStng.get("TOP_PSTN"))) {
|
|
|
|
|
return new float[] {
|
|
|
|
|
sggStng.number("LEFT_PSTN").floatValue(),
|
|
|
|
|
sggStng.number("TOP_PSTN").floatValue()
|
|
|
|
|
toFloat(sggStng.get("LEFT_PSTN")),
|
|
|
|
|
toFloat(sggStng.get("TOP_PSTN"))
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return new float[] {
|
|
|
|
|
@ -814,10 +800,10 @@ public abstract class PDFPrintFormat extends AbstractComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float[] getSize(DefaultOtptArtclStng prototypeStng, DataObject sggStng) {
|
|
|
|
|
if (!sggStng.string("WIDTH_SZ").equals("")) {
|
|
|
|
|
if (!isEmpty(sggStng.get("WIDTH_SZ"))) {
|
|
|
|
|
return new float[] {
|
|
|
|
|
sggStng.number("WIDTH_SZ").floatValue(),
|
|
|
|
|
sggStng.number("HEIGHT_SZ").floatValue()
|
|
|
|
|
toFloat(sggStng.get("WIDTH_SZ")),
|
|
|
|
|
toFloat(sggStng.get("HEIGHT_SZ"))
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
return new float[] {
|
|
|
|
|
|