设置路径的方法:
public String getPath(String path) {
path = ("C:\\" + path + ".pdf");
return path;
}
// 设置字体的方法
public static Font font() {
BaseFont baseFont = null;
try {
baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Font font = new Font(baseFont, 12, Font.BOLD, Color.BLUE);
return font;
}
// 设置字体的方法
public static Font ChineseFont() {
BaseFont baseFont = null;
try {
baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true);
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Font chineseFont = new Font(baseFont, 8, Font.NORMAL, Color.BLUE);
return chineseFont;
}
// 表格是否有数据
public String isNull(Object object) {
if (object == null) {
return "";
}
return object + "";
}
具体设计的代码:
public String getRBPDF(QcyUnitedOrderInfo pageObject) throws Exception {
// TODO Auto-generated method stub
float totalsum = 0;
float totalnum = 0;
List
Paragraph paragraph = new Paragraph("分 部 :", ChineseFont());
paragraph.setSpacingBefore(10);//之前间隔多少
paragraph.setSpacingAfter(10);//之后间隔多少
paragraph.setIndentationLeft(100);//左边缩进设置
Chunk chunk = new Chunk(pageObje