Java Code Examples for com.itextpdf.text.pdf.PdfPCell#setPadding()
The following examples show how to use
com.itextpdf.text.pdf.PdfPCell#setPadding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageHeaderFooterEvent.java From ureport with Apache License 2.0 | 7 votes |
private PdfPCell buildPdfPCell(HeaderFooter phf,String text,int type){ PdfPCell cell=new PdfPCell(); cell.setPadding(0); cell.setBorder(Rectangle.NO_BORDER); Font font=FontBuilder.getFont(phf.getFontFamily(), phf.getFontSize(), phf.isBold(), phf.isItalic(),phf.isUnderline()); String fontColor=phf.getForecolor(); if(StringUtils.isNotEmpty(fontColor)){ String[] color=fontColor.split(","); font.setColor(Integer.valueOf(color[0]), Integer.valueOf(color[1]), Integer.valueOf(color[2])); } Paragraph graph=new Paragraph(text,font); cell.setPhrase(graph); switch(type){ case 1: cell.setHorizontalAlignment(Element.ALIGN_LEFT); break; case 2: cell.setHorizontalAlignment(Element.ALIGN_CENTER); break; case 3: cell.setHorizontalAlignment(Element.ALIGN_RIGHT); break; } cell.setVerticalAlignment(Element.ALIGN_MIDDLE); return cell; }
Example 2
Source File: PDFExport.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
private PdfPCell getCells(MagicCard card) throws BadElementException, IOException { Image image1 = null; try { image1 = Image.getInstance(MTGControler.getInstance().getEnabled(MTGPictureProvider.class).getPicture(card, null), null); } catch (Exception e) { image1 = Image.getInstance(MTGControler.getInstance().getEnabled(MTGPictureProvider.class).getBackPicture(), null); } int h = getInt("CARD_HEIGHT"); int w = getInt("CARD_WIDTH"); image1.scaleAbsolute(w, h); PdfPCell cell = new PdfPCell(image1, false); cell.setBorder(0); cell.setPadding(5); return cell; }
Example 3
Source File: PdfExportDialogFragment.java From geopaparazzi with GNU General Public License v3.0 | 5 votes |
private void addKeyValueToTableRow(PdfPTable table, String key, String value) { PdfPCell keyCell = new PdfPCell(new Paragraph(key)); keyCell.setHorizontalAlignment(Element.ALIGN_CENTER); keyCell.setVerticalAlignment(Element.ALIGN_MIDDLE); keyCell.setPadding(10); table.addCell(keyCell); PdfPCell valueCell = new PdfPCell(new Phrase(value)); valueCell.setHorizontalAlignment(Element.ALIGN_CENTER); valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE); valueCell.setPadding(10); table.addCell(valueCell); }
Example 4
Source File: Helper.java From mobikul-standalone-pos with MIT License | 4 votes |
PdfPCell getPdfCell(Paragraph elements) { PdfPCell pCell = new PdfPCell(); pCell.setPadding(5); pCell.addElement(elements); return pCell; }
Example 5
Source File: PdfProducer.java From ureport with Apache License 2.0 | 4 votes |
private PdfPCell buildPdfPCell(Cell cellInfo,int cellHeight) throws Exception{ CellStyle style=cellInfo.getCellStyle(); CellStyle customStyle=cellInfo.getCustomCellStyle(); CellStyle rowStyle=cellInfo.getRow().getCustomCellStyle(); CellStyle colStyle=cellInfo.getColumn().getCustomCellStyle(); PdfPCell cell=newPdfCell(cellInfo,cellHeight); cell.setPadding(0); cell.setBorder(PdfPCell.NO_BORDER); cell.setCellEvent(new CellBorderEvent(style,customStyle)); int rowSpan=cellInfo.getPageRowSpan(); if(rowSpan>0){ cell.setRowspan(rowSpan); } int colSpan=cellInfo.getColSpan(); if(colSpan>0){ cell.setColspan(colSpan); } Alignment align=style.getAlign(); if(customStyle!=null && customStyle.getAlign()!=null){ align=customStyle.getAlign(); } if(rowStyle!=null && rowStyle.getAlign()!=null){ align=rowStyle.getAlign(); } if(colStyle!=null && colStyle.getAlign()!=null){ align=colStyle.getAlign(); } if(align!=null){ if(align.equals(Alignment.left)){ cell.setHorizontalAlignment(Element.ALIGN_LEFT); }else if(align.equals(Alignment.center)){ cell.setHorizontalAlignment(Element.ALIGN_CENTER); }else if(align.equals(Alignment.right)){ cell.setHorizontalAlignment(Element.ALIGN_RIGHT); } } Alignment valign=style.getValign(); if(customStyle!=null && customStyle.getValign()!=null){ valign=customStyle.getValign(); } if(rowStyle!=null && rowStyle.getValign()!=null){ valign=rowStyle.getValign(); } if(colStyle!=null && colStyle.getValign()!=null){ valign=colStyle.getValign(); } if(valign!=null){ if(valign.equals(Alignment.top)){ cell.setVerticalAlignment(Element.ALIGN_TOP); }else if(valign.equals(Alignment.middle)){ cell.setVerticalAlignment(Element.ALIGN_MIDDLE); }else if(valign.equals(Alignment.bottom)){ cell.setVerticalAlignment(Element.ALIGN_BOTTOM); } } String bgcolor=style.getBgcolor(); if(customStyle!=null && StringUtils.isNotBlank(customStyle.getBgcolor())){ bgcolor=customStyle.getBgcolor(); } if(rowStyle!=null && StringUtils.isNotBlank(rowStyle.getBgcolor())){ bgcolor=rowStyle.getBgcolor(); } if(colStyle!=null && StringUtils.isNotBlank(colStyle.getBgcolor())){ bgcolor=colStyle.getBgcolor(); } if(StringUtils.isNotEmpty(bgcolor)){ String[] colors=bgcolor.split(","); cell.setBackgroundColor(new BaseColor(Integer.valueOf(colors[0]),Integer.valueOf(colors[1]),Integer.valueOf(colors[2]))); } return cell; }
Example 6
Source File: HRPDFBuilderImpl.java From Spring-MVC-Blueprints with MIT License | 4 votes |
@SuppressWarnings("unchecked") @Override protected void buildPdfDocument(Map<String, Object> model, Document doc, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception { // get data model which is passed by the Spring container List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers"); doc.add(new Paragraph("Master List of Users")); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100.0f); table.setWidths(new float[] {3.0f, 2.0f, 2.0f, 2.0f}); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.HELVETICA); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Employee ID", font)); table.addCell(cell); cell.setPhrase(new Phrase("Username", font)); table.addCell(cell); cell.setPhrase(new Phrase("Password", font)); table.addCell(cell); cell.setPhrase(new Phrase("Role", font)); table.addCell(cell); // write table row data for (HrmsLogin user : users) { table.addCell(user.getHrmsEmployeeDetails().getEmpId()+""); table.addCell(user.getUsername()); table.addCell(user.getPassword()); table.addCell(user.getRole()); } doc.add(table); }