修改生成英文证书时英文完整换行
This commit is contained in:
@@ -307,26 +307,26 @@ public class UserCertificateServiceImpl extends ServiceImpl<UserCertificateDao,
|
||||
if ("ZK".equals(type)){
|
||||
des = "Has past the online-examination study of "+edes[0]+" Courses in Tai Hu Education online.";
|
||||
}else {
|
||||
des = "Has satisfactorily completed an online course on "+edes[0]+" with "+edes[1]+" course hours intotal, and has been recongnized eligibility without assessment.";
|
||||
des = "Has satisfactorily completed an online course on "+edes[0]+" with "+edes[1]+" course hours in total, and has been recongnized eligibility without assessment.";
|
||||
}
|
||||
for (int i = 0; i < des.length(); i++) {
|
||||
int oneWordWidth = dess.charWidth(des.charAt(i)); //获取单个字符的长度
|
||||
if (nowWidth+oneWordWidth>700){//换行画
|
||||
String str = "";
|
||||
int nowIndex = 0; //目前一行的长度
|
||||
for (int i = 0; i < des.length(); i++) { //9
|
||||
String tempStr = "";
|
||||
str = str + des.charAt(i);
|
||||
int strWidth = dess.stringWidth(str.substring(nowIndex)); //获取字符的长度
|
||||
if (strWidth>700) {//换行
|
||||
int index = str.lastIndexOf(" ")+1;
|
||||
tempStr = str.substring(nowIndex,index);
|
||||
int writeY = 700 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
g.drawString(tempStr, 155, writeY);
|
||||
alreadyWriteLine++;
|
||||
nowIndex = index;
|
||||
}
|
||||
if (i==des.length()-1){
|
||||
tempStr = str.substring(nowIndex);
|
||||
int writeY = 700 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
g.drawString(des.charAt(i) + "", 155, writeY);
|
||||
nowWidth = 0;
|
||||
space = false;
|
||||
nowWidth += oneWordWidth;
|
||||
}else {//一字一字画
|
||||
int writeY = 700 + alreadyWriteLine * (dess.getHeight()+10);//10是行间距
|
||||
if (nowWidth==0&&space){//首行空一格
|
||||
g.drawString(des.charAt(i)+"", 155+oneWordWidth, writeY);
|
||||
nowWidth += oneWordWidth*2;
|
||||
}else {
|
||||
g.drawString(des.charAt(i)+"", 155+nowWidth, writeY);
|
||||
nowWidth += oneWordWidth;
|
||||
}
|
||||
g.drawString(tempStr, 155, writeY);
|
||||
}
|
||||
}
|
||||
// 释放资源
|
||||
|
||||
Reference in New Issue
Block a user