List of usage examples for com.itextpdf.text.pdf PdfPCell setBorder
public void setBorder(final int border)
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private void remplirCellWithTalk(PdfPCell cell, Talk talk) throws DocumentException, IOException { Image image = AvatarService.INSTANCE.getImage( PdfRenderer.class.getResource("/formats/" + talk.getFormat().replaceAll(" ", "") + ".png")); float[] widths = { 0.15f, 0.85f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100f);/*from ww w .j av a 2s.c o m*/ table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.addCell(image); PdfPCell subCell = new PdfPCell(); Chunk chunk = new Chunk(talk.getTitle(), talkFont); chunk.setLocalGoto("talk" + talk.getId()); Paragraph titleTalk = new Paragraph(); titleTalk.add(chunk); titleTalk.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(titleTalk); Paragraph track = new Paragraph(new Phrase(talk.getTrack(), themeFont)); track.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(track); TalkDetail detail = TalkService.INSTANCE.getTalkDetail(talk); if (detail != null) { for (Speaker speaker : detail.getSpeakers()) { Paragraph speakerText = new Paragraph(speaker.getFullname(), speakerFont); speakerText.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(speakerText); } } subCell.setBorder(Rectangle.NO_BORDER); table.addCell(subCell); cell.setBackgroundColor(mapTrack.get(talk.getTrack())); cell.addElement(table); }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private void createTalksPages(List<Talk> talksToExplain) throws DocumentException, IOException { document.setPageSize(PageSize.A4);/*from w w w . j a va2 s.c om*/ document.newPage(); Paragraph paragraph = new Paragraph("Liste des talks"); paragraph.setSpacingAfter(25); paragraph.getFont().setSize(25); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); for (TalkDetail talk : Lists.transform(talksToExplain, new Function<Talk, TalkDetail>() { @Override public TalkDetail apply(Talk input) { return TalkService.INSTANCE.getTalkDetail(input); } })) { if (talk == null) { continue; } Paragraph empty = new Paragraph(" "); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.setKeepTogether(true); table.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell cell; Chunk titleTalk = new Chunk(talk.getTitle(), talkFontTitle); titleTalk.setLocalDestination("talk" + talk.getId()); float[] withTitle = { 0.05f, 0.95f }; PdfPTable titleWithFormat = new PdfPTable(withTitle); titleWithFormat.getDefaultCell().setBorder(Rectangle.NO_BORDER); titleWithFormat.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); Image image = AvatarService.INSTANCE.getImage(PdfRenderer.class .getResource("/formats/" + talk.getTalk().getFormat().replaceAll(" ", "") + ".png")); titleWithFormat.addCell(image); titleWithFormat.addCell(new Paragraph(titleTalk)); table.addCell(titleWithFormat); table.addCell(empty); table.addCell(new Paragraph("Salle " + talk.getTalk().getRoom() + " de " + talk.getTalk().getStart() + " " + talk.getTalk().getEnd(), presentFont)); table.addCell(empty); cell = new PdfPCell(); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); for (Element element : HTMLWorker .parseToList(new StringReader(markdownProcessor.markdown(talk.getDescription())), null)) { if (element instanceof Paragraph) { ((Paragraph) element).setAlignment(Element.ALIGN_JUSTIFIED); } cell.addElement(element); } table.addCell(cell); table.addCell(empty); table.addCell(new Paragraph("Prsent par :", presentFont)); float[] widthSpeaker = { 0.05f, 0.95f }; for (Speaker speaker : talk.getSpeakers()) { PdfPTable speakerWithAvatar = new PdfPTable(widthSpeaker); speakerWithAvatar.getDefaultCell().setBorder(Rectangle.NO_BORDER); speakerWithAvatar.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); speakerWithAvatar.addCell(AvatarService.INSTANCE.getImage(speaker.getAvatar())); speakerWithAvatar.addCell(new Phrase(speaker.getFullname())); table.addCell(speakerWithAvatar); } table.addCell(empty); table.addCell(empty); document.add(table); } }
From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java
License:Apache License
private void remplirCellWithTalk(PdfPCell cell, Talk talk) throws DocumentException, IOException { Image image = AvatarService.INSTANCE.getImage( RoomPdfRenderer.class.getResource("/formats/" + talk.getFormat().replaceAll(" ", "") + ".png")); float[] widths = { 0.05f, 0.95f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100f);//w w w.j ava2 s .c om table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.addCell(image); PdfPCell subCell = new PdfPCell(); Chunk chunk = new Chunk(talk.getTitle(), talkFont); chunk.setLocalGoto("talk" + talk.getId()); Paragraph titleTalk = new Paragraph(); titleTalk.add(chunk); titleTalk.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(titleTalk); Paragraph track = new Paragraph(new Phrase(talk.getTrack(), themeFont)); track.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(track); TalkDetail detail = TalkService.INSTANCE.getTalkDetail(talk); if (detail != null) { for (Speaker speaker : detail.getSpeakers()) { Paragraph speakerText = new Paragraph(speaker.getFullname(), speakerFont); speakerText.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(speakerText); } } subCell.setBorder(Rectangle.NO_BORDER); table.addCell(subCell); cell.setBackgroundColor(mapTrack.get(talk.getTrack())); cell.addElement(table); }
From source file:Functions.pdf_Export.java
public void createHeader(Document doc, Integer soHoaDon) { try {//w ww . jav a 2 s.co m PdfPTable table = new PdfPTable(new float[] { 80, 20 }); table.setWidthPercentage(100); LinkedHashMap<String, Font> lines = new LinkedHashMap<>(); lines.put("Shop Name: " + shopName, titleFont); lines.put("Address: " + address, smallFont); lines.put("Phone Number: " + phoneNumb, smallFont); lines.put("Website: " + web, smallFont); lines.put("Email: " + email, smallFont); // left cell with shop's infor PdfPCell leftCell = new PdfPCell(); leftCell.setPaddingTop(-7); leftCell.setPaddingRight(35); Set<String> singleLine = lines.keySet(); // this below loop to create a line with text, and set it's font for (String line : singleLine) { leftCell.addElement(new Phrase(line, lines.get(line))); } leftCell.setHorizontalAlignment(Element.ALIGN_LEFT); leftCell.setBorder(PdfPCell.NO_BORDER); table.addCell(leftCell); // right cell with bill's time String time = new HoaDonDAO().getHoaDon(soHoaDon).getNgayLapHoaDon().toString(); PdfPCell rightCell = new PdfPCell(); rightCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); rightCell.addElement(new Phrase("Date: " + time + "\nNo.: " + soHoaDon, smallFont)); rightCell.setBorder(PdfPCell.NO_BORDER); table.addCell(rightCell); doc.add(table); } catch (DocumentException ex) { Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Functions.pdf_Export.java
private void createFooter(Document doc, HoaDon hoaDon, NhanVien nv, KhachHang kh) { try {// w w w .j a va 2 s . co m String total = new DecimalFormat("#,###").format(hoaDon.getTongTien()); Paragraph paragraph = new Paragraph(); paragraph.add(new Phrase("Total: " + total + " (VND)", smallFont)); paragraph.setAlignment(Element.ALIGN_RIGHT); addEmptyLine(paragraph, 3); doc.add(paragraph); PdfPTable table = new PdfPTable(2); PdfPCell cell = new PdfPCell(new Phrase("Sale Staff", subFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorder(0); table.addCell(cell); cell.setPhrase(new Phrase("Customer", subFont)); table.addCell(cell); // add 3 blank row for (Integer i = 0; i < 10; i++) { cell.setPhrase(new Phrase(" ")); table.addCell(cell); } cell.setPhrase(new Phrase(nv.getHoTenNhanVien(), smallFont)); table.addCell(cell); cell.setPhrase(new Phrase(kh.getHoTenKH(), smallFont)); table.addCell(cell); doc.add(table); paragraph = new Paragraph(); addEmptyLine(paragraph, 5); paragraph.add(new Phrase( "Bill generated by: " + nv.getHoTenNhanVien() + " - " + nv.getMaNhanVien() + ", " + new Date(), italicFont)); doc.add(paragraph); } catch (DocumentException ex) { Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fxml.test.PDFService.java
private PdfPTable createDocumentHeader() throws IOException, BadElementException { //start creating header for the document...... PdfPTable headerTable = new PdfPTable(3); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*from w ww .j a v a 2 s. com*/ headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f }); headerTable.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg")); image.scalePercent(42f); image.setAlignment(Element.ALIGN_LEFT); PdfPCell imageCell = new PdfPCell(image, false); imageCell.setPaddingTop(6); imageCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(imageCell); //start info table..... PdfPTable infoTable = new PdfPTable(1); infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH"; String tabulationText = "TABULATION SHEET"; String deptText = inputs.get(0).trim(); String s1 = inputs.get(1).trim(); String s2 = inputs.get(2).trim(); String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2); String session = inputs.get(3).trim(); String date = inputs.get(4).trim(); String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date); infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true)); infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); //end info table..... PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(infoCell); PdfPCell resultPublishDateCell = new PdfPCell( new Paragraph("Result Published On............................", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD))); resultPublishDateCell.setBorder(Rectangle.NO_BORDER); resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(resultPublishDateCell); headerTable.setSpacingAfter(17.5f); // System.err.println("completed header table"); return headerTable; //end creating header for the document...... }
From source file:fxml.test.PDFService.java
public PdfPTable createFooter1() { //String[] names = new String[]{"Md. Eamin Rahman", "Md. Mujibur Rahman", "Md Masum", "Md. Saiful Islam", "Husne Ara Chowdhury", "Sabir Ismail"}; PdfPTable table = new PdfPTable(5); table.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*from ww w.j av a 2s . co m*/ table.setTotalWidth(new float[] { 161f, 161f, 133f, 167f, 161f }); table.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } //table.setWidthPercentage(100); PdfPCell chairmanSIgnature = new PdfPCell(new Paragraph("Signature of the Chairman:", font9)); chairmanSIgnature.setBorder(Rectangle.NO_BORDER); chairmanSIgnature.setPaddingLeft(0f); chairmanSIgnature.setPaddingTop(5); table.addCell(chairmanSIgnature); PdfPCell underLine = new PdfPCell(new Paragraph("_______________________")); underLine.setBorder(Rectangle.NO_BORDER); table.addCell(underLine); PdfPCell blankColumn = new PdfPCell(new Paragraph(" ")); blankColumn.setBorder(Rectangle.NO_BORDER); table.addCell(blankColumn); Paragraph p = new Paragraph("Signature of The Controller of Examinations:", font9); p.setLeading(0, 1.3f); PdfPCell controllerSignature = new PdfPCell(); controllerSignature.addElement(p); controllerSignature.setBorder(Rectangle.NO_BORDER); table.addCell(controllerSignature); table.addCell(underLine); PdfPCell cell1 = new PdfPCell(new Paragraph(inputs.get(5).trim(), font9)); cell1.setPaddingTop(0f); cell1.setBorder(Rectangle.NO_BORDER); PdfPCell cell2 = new PdfPCell(new Paragraph(inputs.get(6).trim(), font9)); cell2.setPaddingTop(0f); cell2.setBorder(Rectangle.NO_BORDER); PdfPCell nameColumn = new PdfPCell(new Paragraph("Name :", font9)); nameColumn.setBorder(Rectangle.NO_BORDER); nameColumn.setPaddingLeft(0f); nameColumn.setPaddingTop(0f); PdfPCell nameColumn2 = new PdfPCell(new Paragraph("Name :", font9)); nameColumn2.setBorder(Rectangle.NO_BORDER); nameColumn2.setPaddingTop(0f); table.addCell(nameColumn); table.addCell(cell1); table.addCell(blankColumn); table.addCell(nameColumn2); table.addCell(cell2); table.setSpacingAfter(23.5f); return table; }
From source file:fxml.test.PDFService.java
public PdfPTable createFooter2() { PdfPTable table = new PdfPTable(8); table.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*w w w . j av a2 s. co m*/ table.setTotalWidth(new float[] { 192f, 144f, 5f, 144f, 5f, 144f, 5f, 144f }); table.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } PdfPCell underLine = new PdfPCell(new Paragraph("_____________________")); underLine.setBorder(Rectangle.NO_BORDER); PdfPCell blankColumn = new PdfPCell(new Paragraph(" ")); blankColumn.setBorder(Rectangle.NO_BORDER); PdfPCell blankColumn2 = new PdfPCell(new Paragraph(" ")); blankColumn2.setBorder(Rectangle.BOTTOM); PdfPCell nameColumn = new PdfPCell(new Paragraph("Name :", font9)); nameColumn.setBorder(Rectangle.NO_BORDER); nameColumn.setPaddingLeft(0f); PdfPCell cell3 = new PdfPCell(new Paragraph(inputs.get(7).trim(), font9)); cell3.setPaddingRight(2); cell3.setBorder(Rectangle.TOP); PdfPCell cell4 = new PdfPCell(new Paragraph(inputs.get(8).trim(), font9)); cell4.setBorder(Rectangle.TOP); PdfPCell cell5 = new PdfPCell(new Paragraph(inputs.get(9).trim(), font9)); cell5.setBorder(Rectangle.TOP); PdfPCell cell6 = new PdfPCell(new Paragraph(inputs.get(10).trim(), font9)); cell6.setBorder(Rectangle.TOP); PdfPCell memberSignature = new PdfPCell(new Paragraph("Signature of the Members:", font9)); memberSignature.setPaddingLeft(0f); memberSignature.setBorder(Rectangle.NO_BORDER); table.addCell(memberSignature); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(blankColumn); table.addCell(nameColumn); table.addCell(cell3); table.addCell(blankColumn); table.addCell(cell4); table.addCell(blankColumn); table.addCell(cell5); table.addCell(blankColumn); table.addCell(cell6); PdfPCell tabulatorSignature = new PdfPCell(new Paragraph("Signature of the Tabulators:", font9)); tabulatorSignature.setPaddingLeft(0f); tabulatorSignature.setPaddingTop(13f); tabulatorSignature.setBorder(Rectangle.NO_BORDER); table.addCell(tabulatorSignature); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); table.addCell(blankColumn); table.addCell(blankColumn2); return table; }
From source file:fxml.test.PDFService.java
public PdfPCell getCellForString(String args, int colSpan, boolean border, int vertical, int horizontal, Font font, boolean wrap) { PdfPCell cell = new PdfPCell(new Paragraph(args, font)); if (colSpan != 0) { cell.setColspan(colSpan);/* ww w . jav a 2 s . co m*/ } cell.setVerticalAlignment(vertical); cell.setHorizontalAlignment(horizontal); if (!border) { cell.setBorder(Rectangle.NO_BORDER); } if (wrap) { cell.setNoWrap(true); } return cell; }
From source file:fxml.test.PDFService.java
public PdfPCell getCellForHeaderString(String args, int colSpan, boolean flag, int vertical, int horizontal, Font font, boolean wrap) { PdfPCell cell = new PdfPCell(new Paragraph(args, font)); if (colSpan != 0) { cell.setColspan(colSpan);//w w w. j a v a 2 s. c o m } cell.setVerticalAlignment(vertical); cell.setHorizontalAlignment(horizontal); cell.setPaddingTop(0.8f); if (!flag) { cell.setBorder(Rectangle.NO_BORDER); } if (wrap) { cell.setNoWrap(true); } return cell; }