
private static final int topValue = 2;
private static final int leftValue = 0;
private static final int rightValue = 0;
private static final int bottomValue = 0;
private static final int userSpaceWidth = 1150;
private static PD4ML pd4ml = null;
private Pd4Util(){}
private static class Pd4mlUtilHolder{
private final static Pd4Util instance = new Pd4Util();
}
public static Pd4Util getInstance(){
return Pd4mlUtilHolder.instance;
}
public static PD4ML getPD4ml() throws Exception{
if (pd4ml == null){
synchronized (Pd4Util.class){
pd4ml = new PD4ML();
pd4ml.setHtmlWidth(userSpaceWidth);
pd4ml.setPageSize(pd4ml.changePageOrientation(PD4Constants.A4));
pd4ml.setPageInsetsMM(new Insets(topValue, leftValue, bottomValue, rightValue));
pd4ml.addStyle("body {margin: 0; letter-spacing:1px;}", true);
pd4ml.addStyle(" table{word-wrap:break-word; word-break:break-all; border-collapse:collapse; cellpadding='1'; cellspacing='1';}", true);
pd4ml.addStyle(" #table-css td, tr{ border:1.5px solid #000; padding:0.2em; }", true);
try {
pd4ml.useTTF("java:fonts",true);
} catch (FileNotFoundException e) {
e.printStackTrace();
throw new Exception("pd4ml插件初始化出错");
}
pd4ml.setDefaultTTFs("SIMHEI", "SIMHEI", "Arial");
Dimension dimension = new Dimension(210, 297);
pd4ml.setPageSizeMM(dimension);
pd4ml.enableDebugInfo();
}
}
return pd4ml;
}