List of usage examples for com.itextpdf.text.pdf PdfPCell setBorder
public void setBorder(final int border)
From source file:naprawa.praca.PracaController.java
public PdfPTable addTableCzesc() { PdfPTable tableCzesc = new PdfPTable(3); try {//from w ww. j av a 2s . c o m tableCzesc.setWidthPercentage(100); int[] width = { 8, 77, 15 }; tableCzesc.setWidths(width); PdfPCell cell = getNewCell("Czci"); cell.setColspan(10); cell.setBorder(PdfPCell.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableCzesc.addCell(cell); int i = 1; for (Object item : mapaUslug.get(RodzajUslugi.CZESC)) { Czesc czesc = ((Czesc) item); tableCzesc.addCell(getNewCell(i + ".")); tableCzesc.addCell(getNewCell(czesc.getOpis())); tableCzesc.addCell(getNewCell(TO_Invoice.getWynikSumaKoszt(czesc.getCena()) + " z")); i++; } } catch (DocumentException ex) { Logger.getLogger(PracaController.class.getName()).log(Level.SEVERE, null, ex); } return tableCzesc; }
From source file:naprawa.praca.PracaController.java
public PdfPTable addTableCzescService(String rodzaj, RodzajUslugi usluga) { PdfPTable tableCzesc = new PdfPTable(3); try {//from w w w.ja v a 2s . c o m tableCzesc.setWidthPercentage(100); int[] width = { 8, 77, 15 }; tableCzesc.setWidths(width); PdfPCell cell = getNewCell(rodzaj); cell.setColspan(10); cell.setBorder(PdfPCell.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableCzesc.addCell(cell); int i = 1; for (Object item : mapaUslug.get(usluga)) { Usluga czesc = ((Usluga) item); tableCzesc.addCell(getNewCell(i + ".")); tableCzesc.addCell(getNewCell(czesc.getOpis())); tableCzesc.addCell(getNewCell(TO_Invoice.getWynikSumaKoszt(czesc.getKoszt()) + " z")); i++; } } catch (DocumentException ex) { Logger.getLogger(PracaController.class.getName()).log(Level.SEVERE, null, ex); } return tableCzesc; }
From source file:naprawa.praca.PracaController.java
public PdfPCell getNewCell(String nazwa) { BaseFont bf = null;/* w ww . j a v a2s . co m*/ try { bf = BaseFont.createFont("c:/windows/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); } catch (DocumentException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell cell = new PdfPCell(new Paragraph(nazwa, new com.itextpdf.text.Font(bf, 10))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_LEFT); cell.setBorder(PdfPCell.NO_BORDER); return cell; }
From source file:net.digitstar.vanadio.AbstractReportPdf.java
License:Apache License
protected PdfPTable createHeader(Document document, int page, int pageTotal, ReportOptions reportOptions) { PdfPTable header = new PdfPTable(3); header.setTotalWidth(document.right() - document.left()); PdfPCell def = header.getDefaultCell(); String left = ""; String center = ""; String right = ""; if (reportOptions.isShowPageNumberIfOnePage() || (!reportOptions.isShowPageNumberIfOnePage() && pageTotal > 1)) { right = reportOptions.isShowPageTotal() ? Labels.PAGE_TOTAL.getLabelFormatted(page, pageTotal) : Labels.PAGE.getLabelFormatted(page); }//w w w . j a v a2s . c o m def.setFixedHeight(computeHeight(FontType.HEADERFOOTER.getFont())); def.setBorder(CellStyle.Border.NONE.getValue()); if (reportOptions.isUseHrRuler()) def.setBorder(CellStyle.Border.BOTTOM.getValue()); def.setHorizontalAlignment(CellStyle.Align.LEFT.getValue()); header.addCell(new Phrase(left, FontType.HEADERFOOTER.getFont())); def.setHorizontalAlignment(CellStyle.Align.CENTER.getValue()); header.addCell(new Phrase(center, FontType.HEADERFOOTER.getFont())); def.setHorizontalAlignment(CellStyle.Align.RIGHT.getValue()); header.addCell(new Phrase(right, FontType.HEADERFOOTER.getFont())); return header; }
From source file:net.digitstar.vanadio.AbstractReportPdf.java
License:Apache License
protected PdfPTable createFooter(Document document, int page, int pageTotal, ReportOptions reportOptions) { PdfPTable footer = new PdfPTable(3); footer.setTotalWidth(document.right() - document.left()); PdfPCell def = footer.getDefaultCell(); String left = ""; String center = ""; String right = ""; def.setFixedHeight(computeHeight(FontType.HEADERFOOTER.getFont())); def.setBorder(CellStyle.Border.NONE.getValue()); if (reportOptions.isUseHrRuler()) def.setBorder(CellStyle.Border.TOP.getValue()); if (reportOptions.isShowPrintDate()) right = Labels.PRINTED.getLabelFormatted(getDateTimeFormat().format(new Date())); def.setHorizontalAlignment(CellStyle.Align.LEFT.getValue()); footer.addCell(new Phrase(left, FontType.HEADERFOOTER.getFont())); def.setHorizontalAlignment(CellStyle.Align.CENTER.getValue()); footer.addCell(new Phrase(center, FontType.HEADERFOOTER.getFont())); def.setHorizontalAlignment(CellStyle.Align.RIGHT.getValue()); footer.addCell(new Phrase(right, FontType.HEADERFOOTER.getFont())); return footer; }
From source file:net.digitstar.vanadio.helpers.PdfHelper.java
License:Apache License
public static PdfPCell newCell(CellStyle style) { PdfPCell cell = new PdfPCell(); if (style != null) { if (style.getNestedTable() != null) { cell = new PdfPCell(style.getNestedTable()); style.setNestedTable(null);//from www . j a v a2 s . c om } else if (style.getImage() != null) { cell = new PdfPCell(style.getImage(), style.isFitImage()); style.setImage(null); } else if (style.getText() != null) { cell = new PdfPCell(style.getText()); style.setText((String) null); } cell.setColspan(style.getColspan()); cell.setRowspan(style.getRowspan()); cell.setMinimumHeight(style.getMinimumHeight()); cell.setFixedHeight(style.getFixedHeight()); cell.setNoWrap(style.isNoWrap()); cell.setRotation(style.getRotation().getValue()); style = Alignment.assign(style); cell.setHorizontalAlignment(style.getHorizAlign().getValue()); cell.setVerticalAlignment(style.getVertAlign().getValue()); cell.setUseVariableBorders(style.isUseVariableBorders()); cell.setUseBorderPadding(style.isUseBorderPadding()); if (!style.getBorderWidth().isAllSideEqual()) { cell.setBorderWidthBottom(style.getBorderWidth().getBottom()); cell.setBorderWidthLeft(style.getBorderWidth().getLeft()); cell.setBorderWidthRight(style.getBorderWidth().getRight()); cell.setBorderWidthTop(style.getBorderWidth().getTop()); } else { cell.setBorderWidth(style.getBorderWidth().getValue()); } cell.setPaddingBottom(style.getPadding().getBottom()); cell.setPaddingLeft(style.getPadding().getLeft()); cell.setPaddingRight(style.getPadding().getRight()); cell.setPaddingTop(style.getPadding().getTop()); cell.setBorderColorBottom(style.getBorderColor().getBottom()); cell.setBorderColorLeft(style.getBorderColor().getLeft()); cell.setBorderColorRight(style.getBorderColor().getRight()); cell.setBorderColorTop(style.getBorderColor().getTop()); cell.setBorder(style.getBorder().getValue()); cell.setBackgroundColor(style.getBackgroundColor()); if (style.getGreyFill() >= 0) { cell.setGrayFill(style.getGreyFill()); } } return cell; }
From source file:net.vzurczak.timesheetgenerator.PdfGenerator.java
License:Apache License
/** * Adds a page for a given week.//from w w w. ja v a 2 s . c o m * @param i the week number * @param doc the document to update * @param bean a generation bean (not null) * @throws DocumentException */ private void addPageForWeek(int weekNumber, Document doc, GenerationDataBean bean) throws DocumentException { doc.newPage(); final Font boldFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD); final Font normalFont = FontFactory.getFont(FontFactory.HELVETICA); Calendar calendar = Utils.findCalendar(weekNumber); // Title Paragraph paragraph = new Paragraph("Bordereau de Dclaration des Temps", boldFont); paragraph.setAlignment(Element.ALIGN_CENTER); doc.add(paragraph); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); // Meta: week final PdfPTable metaTable = new PdfPTable(1); paragraph = new Paragraph(); paragraph.add(new Chunk("Semaine : ", boldFont)); paragraph.add(new Chunk(String.valueOf(weekNumber), normalFont)); PdfPCell c = new PdfPCell(paragraph); c.setBorder(Rectangle.NO_BORDER); metaTable.addCell(c); // Meta: date Calendar endOfWeekCalendar = ((Calendar) calendar.clone()); endOfWeekCalendar.add(Calendar.DATE, 4); String formattedDate = new SimpleDateFormat("dd/MM/yyyy").format(endOfWeekCalendar.getTime()); paragraph = new Paragraph(); paragraph.add(new Chunk("Date : ", boldFont)); paragraph.add(new Chunk(formattedDate, normalFont)); c = new PdfPCell(paragraph); c.setBorder(Rectangle.NO_BORDER); metaTable.addCell(c); doc.add(metaTable); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); // Signatures final PdfPTable signaturesTable = new PdfPTable(2); paragraph = new Paragraph(); paragraph.add(new Chunk("Nom : ", boldFont)); paragraph.add(new Chunk(bean.getName(), normalFont)); c = new PdfPCell(paragraph); c.setBorder(Rectangle.NO_BORDER); signaturesTable.addCell(c); paragraph = new Paragraph(); paragraph.add(new Chunk("Responsable : ", boldFont)); paragraph.add(new Chunk(bean.getManagerName(), normalFont)); c = new PdfPCell(paragraph); c.setBorder(Rectangle.NO_BORDER); signaturesTable.addCell(c); c = new PdfPCell(new Paragraph("Signature : ", boldFont)); c.setBorder(Rectangle.NO_BORDER); signaturesTable.addCell(c); c = new PdfPCell(new Paragraph("Signature : ", boldFont)); c.setBorder(Rectangle.NO_BORDER); signaturesTable.addCell(c); doc.add(signaturesTable); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); // Calendar final PdfPTable timeTable = new PdfPTable(7); timeTable.addCell(new PdfPCell()); for (int i = 0; i < 5; i++) { final String date = this.sdf.format(calendar.getTime()); timeTable.addCell(newCell(date, 10)); calendar.add(Calendar.DATE, 1); } timeTable.addCell(newCell("Total", 10)); timeTable.addCell(newCell("Heures Effectues", 20)); for (int i = 0; i < 5; i++) timeTable.addCell(newCell("", 20)); if (bean.getTotalHours() > 0) timeTable.addCell(newCell(bean.getTotalHours() + " h", 20)); timeTable.completeRow(); doc.add(timeTable); }
From source file:net.yuvideo.voipRacuni.classes.PrintPageListing.java
public void createListing() { document.open();//from ww w. j a v a2 s . c o m PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); //HEADERS PdfPCell cell = new PdfPCell(new Phrase("IZVETAJ-LISTING", fontBold)); cell.setColspan(5); cell.setBorder(0); table.addCell(cell); //HEADER KORISNIK String korisnik; if (user.isFirma()) { korisnik = user.getNazivFirme(); } else { korisnik = user.getIme(); } cell = new PdfPCell( new Phrase(String.format("%s - %s - %s", korisnik, user.getBrojTelefona(), this.period), font)); cell.setColspan(5); cell.setBorder(0); table.addCell(cell); //HEADER TABLE PdfPCell cellH1 = new PdfPCell(new Phrase("br.", fontBold)); cellH1.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cellH1).setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellH2 = new PdfPCell(new Phrase("Pozivani broj", fontBold)); cellH2.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cellH2).setHorizontalAlignment(1); PdfPCell cellH3 = new PdfPCell(new Phrase("Destinacija", fontBold)); cellH3.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cellH3).setHorizontalAlignment(1); PdfPCell cellH4 = new PdfPCell(new Phrase("Vreme", fontBold)); cellH4.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cellH4).setHorizontalAlignment(1); PdfPCell cellH5 = new PdfPCell(new Phrase("Trajanje poziva", fontBold)); cellH5.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cellH5).setHorizontalAlignment(1); PdfPCell cellIzvestaj; int ukupno = 0; for (izvestajPotrosnje izvestaj : listing) { //potrosnja ukupno //Redni broj cellIzvestaj = new PdfPCell(new Phrase(String.valueOf(izvestaj.br), font)); cellIzvestaj.setHorizontalAlignment(1); cellIzvestaj.setVerticalAlignment(5); table.addCell(cellIzvestaj); //Pozivani broj cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getSource(), font)); cellIzvestaj.setHorizontalAlignment(1); cellIzvestaj.setVerticalAlignment(5); table.addCell(cellIzvestaj); //Destinacija cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getDestination(), font)); cellIzvestaj.setHorizontalAlignment(1); cellIzvestaj.setVerticalAlignment(5); table.addCell(cellIzvestaj); //Vreme cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getDatumPoziva(), font)); cellIzvestaj.setHorizontalAlignment(1); cellIzvestaj.setVerticalAlignment(5); table.addCell(cellIzvestaj); //trajanje poziva cellIzvestaj = new PdfPCell(new Phrase(izvestaj.getTrajanje(), font)); cellIzvestaj.setHorizontalAlignment(1); cellIzvestaj.setVerticalAlignment(5); table.addCell(cellIzvestaj); ukupno = izvestaj.getUkupno_poziv(); } PdfPCell footer = new PdfPCell(new Phrase( String.format("Ukupno: %s", LocalTime.MIN.plusSeconds(ukupno).toString()), fontLargeBold)); footer.setColspan(5); footer.setHorizontalAlignment(2); footer.setBorder(0); table.addCell(footer); try { document.add(table); } catch (DocumentException ex) { Logger.getLogger(PrintPageListing.class.getName()).log(Level.SEVERE, null, ex); } document.close(); }
From source file:nl.infosys.hartigehap.barSystem.domain.Bon.java
/** * create the table for the PDF/*from ww w . j a v a2 s. co m*/ * * @return table */ private Paragraph table() { Paragraph par = new Paragraph(); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); PdfPCell cell; Font fontbold = FontFactory.getFont("Times-Roman", 13, Font.BOLD); Font normal = FontFactory.getFont("Times-Roman", 13); table.addCell(new Phrase("Product:", fontbold)); table.addCell(new Phrase("Prijs:", fontbold)); table.addCell(new Phrase("Aantal:", fontbold)); table.addCell(new Phrase("Totaalprijs:", fontbold)); for (ImmutableProduct product : bestelling.getProducten()) { table.addCell(new Phrase(product.getNaam(), normal)); table.addCell(new Phrase(product.getPrijsFormat(), normal)); table.addCell(new Phrase(String.valueOf(product.getAantal()), normal)); cell = new PdfPCell(new Phrase(product.getTotaalPrijsFormat(), normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase("Excl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getPrijsExclBtwFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase("BTW 21%", fontbold)); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getBtwBedragFormat(), fontbold)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("Incl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getTotaalPrijsFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); par.add(table); return par; }
From source file:nl.infosys.hartigehap.barSystem.presentation.BonGui.java
private Paragraph table() { Paragraph par = new Paragraph(); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100);//from ww w.j av a 2 s . co m table.getDefaultCell().setBorder(0); PdfPCell cell; Font fontbold = FontFactory.getFont("Times-Roman", 13, Font.BOLD); Font normal = FontFactory.getFont("Times-Roman", 13); table.addCell(new Phrase("Product:", fontbold)); table.addCell(new Phrase("Prijs:", fontbold)); table.addCell(new Phrase("Aantal:", fontbold)); table.addCell(new Phrase("Totaalprijs:", fontbold)); for (ImmutableProduct product : bestelling.getProducten()) { table.addCell(new Phrase(product.getNaam(), normal)); table.addCell(new Phrase(product.getPrijsFormat(), normal)); table.addCell(new Phrase(String.valueOf(product.getAantal()), normal)); cell = new PdfPCell(new Phrase(product.getTotaalPrijsFormat(), normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase("Excl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getPrijsExclBtwFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase("BTW 21%", fontbold)); cell.setBorder(0); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getBtwBedragFormat(), fontbold)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Phrase("Incl. BTW", fontbold)); cell.setBorder(Rectangle.TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(bestelling.getTotaalPrijsFormat(), fontbold)); cell.setColspan(3); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.TOP); table.addCell(cell); par.add(table); return par; }