コード例 #1
0
 public PdfPCell printStrTopLine(
     String text, int colspan, int fontsize, boolean bold, boolean border, int align) {
   try {
     if (text == null) text = "";
     Paragraph p = new Paragraph();
     float padding = 3.0f;
     // set bold feature
     if (bold) {
       p.add(new Chunk(text, new Font(Font.getFamilyIndex("Arial"), fontsize, Font.BOLD)));
       padding = 3.0f;
     } else p.add(new Chunk(text, new Font(Font.getFamilyIndex("Arial"), fontsize)));
     PdfPCell cell = new PdfPCell(p);
     // set colspan feature
     cell.setColspan(colspan);
     // set alignment feature
     if (align == 0) cell.setHorizontalAlignment(cell.ALIGN_LEFT);
     else if (align == 1) cell.setHorizontalAlignment(cell.ALIGN_CENTER);
     else if (align == 2) cell.setHorizontalAlignment(cell.ALIGN_RIGHT);
     // set border feature
     cell.setBorder(cell.NO_BORDER);
     cell.setBorder(cell.TOP);
     cell.setPaddingBottom(padding);
     return cell;
   } catch (Exception e) {
     return null;
   }
 }
コード例 #2
0
 public PdfPCell printStrBoldUnderline(String text, int colspan, int fontsize, int align) {
   try {
     Paragraph p = new Paragraph();
     float padding = 3f;
     // set bold feature
     p.add(new Chunk(text, new Font(Font.getFamilyIndex("Arial"), fontsize, Font.BOLD)));
     PdfPCell cell = new PdfPCell(p);
     // set colspan feature
     cell.setColspan(colspan);
     // set alignment feature
     if (align == 0) cell.setHorizontalAlignment(cell.ALIGN_LEFT);
     else if (align == 1) cell.setHorizontalAlignment(cell.ALIGN_CENTER);
     else if (align == 2) cell.setHorizontalAlignment(cell.ALIGN_RIGHT);
     // set border feature
     cell.disableBorderSide(cell.LEFT);
     cell.disableBorderSide(cell.RIGHT);
     cell.disableBorderSide(cell.TOP);
     cell.setPaddingBottom(padding);
     return cell;
   } catch (Exception e) {
     return null;
   }
 }