출력물 텍스트정렬 수정

main
이범준 11 months ago
parent 6e18fe80df
commit 02b2c17bef

@ -25,9 +25,9 @@ public class PDFPrintUtil extends PrintUtil {
public void setting(String paperType) {
if(paperType.equals("01")) {
this.paperMilimeter = new float[] {210 , 297};
this.paperMilimeter = new float[] {210.0f , 297.0f};
} else if(paperType.equals("02")){
this.paperMilimeter = new float[] {216 , 279};
this.paperMilimeter = new float[] {216.0f , 279.0f};
}
}
@ -54,7 +54,9 @@ public class PDFPrintUtil extends PrintUtil {
}
//
/**
* mm pdf .
*/
public PDFCoordinate toPDFCoordinate(float[] XYmm) {
float Xmm = XYmm[0];
float Ymm = XYmm[1];
@ -67,7 +69,9 @@ public class PDFPrintUtil extends PrintUtil {
return new PDFCoordinate(Xpt, Ypt, YptMax);
}
//
/**
* pdf .
*/
public void writeText(PDPageContentStream contentStream, String allText,
float[] XYmm, float textAreaWidth_mm, String align, String newLineYn,
PDType0Font font, int fontSize, RenderingMode fontStyle, PDColor fontColor) {
@ -112,7 +116,7 @@ public class PDFPrintUtil extends PrintUtil {
if(align.equals("right")) {
firstLineAlignCorrection = textAreaWidth_pt - firstLineWidth;
} else if(align.equals("center")) {
firstLineAlignCorrection = (textAreaWidth_pt - firstLineWidth)/2;
firstLineAlignCorrection = (textAreaWidth_pt - firstLineWidth)/2.0f;
}
float resultX = xyAbsolute[0] + firstLineAlignCorrection;
@ -121,6 +125,7 @@ public class PDFPrintUtil extends PrintUtil {
contentStream.showText(textArr[0]);
if(textArr.length > 1) {
float beforeLineWidth = firstLineWidth;
for(int i = 1; i < textArr.length; i++) {
String thisLine = textArr[i];
@ -128,13 +133,15 @@ public class PDFPrintUtil extends PrintUtil {
float alignCorrection = 0;
if(align.equals("right")) {
alignCorrection = firstLineWidth - thisLineWidth;
alignCorrection = beforeLineWidth - thisLineWidth;
} if(align.equals("center")) {
alignCorrection = (firstLineWidth - thisLineWidth)/2;
alignCorrection = (beforeLineWidth - thisLineWidth)/2.0f;
}
contentStream.newLineAtOffset(alignCorrection, -(fontSize + 1));
contentStream.showText(thisLine);
beforeLineWidth = thisLineWidth;
}
@ -148,7 +155,9 @@ public class PDFPrintUtil extends PrintUtil {
}
/**
* , (pt) .
*/
public float calcTextWidth(PDType0Font font, int fontSize, String text) {
try {
return (font.getStringWidth(text) / 1000.0f) * fontSize;
@ -157,6 +166,9 @@ public class PDFPrintUtil extends PrintUtil {
}
}
/**
* .
*/
public String[] splitByLineForLargeText(PDType0Font font, int fontSize, String allText, float textAreaWidth_pt) {
float allTextWidth = calcTextWidth(font, fontSize, allText);
@ -179,6 +191,9 @@ public class PDFPrintUtil extends PrintUtil {
return textList.toArray(new String[textList.size()]);
}
/**
* .
*/
private int getLengthForLine(PDType0Font font, int fontSize, String allText, float textAreaWidth_pt) {
int forLine = allText.length();
if(forLine <= 1) {
@ -199,6 +214,9 @@ public class PDFPrintUtil extends PrintUtil {
return forLine;
}
/**
* pdf .
*/
public void insertImage(PDDocument doc, PDPageContentStream contentStream, String imagePath, float[] XYmm,
float[] SIZEmm) {

Loading…
Cancel
Save