List of usage examples for com.itextpdf.text.pdf PdfPCell setBorderWidth
public void setBorderWidth(final float borderWidth)
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterUnterschriftenLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Schulleiter(in)", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f); leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f);/*www . j a v a2s . c o m*/ centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont)); rightCell.setBorder(Rectangle.TOP); rightCell.setBorderWidth(1f); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f); table.addCell(leftCell); table.addCell(centerCell); table.addCell(rightCell); table.setWidths(new float[] { 0.3f, 0.3f, 0.3f }); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterKenntnisLine(Font footerFont) { PdfPCell cell = new PdfPCell(new Phrase("Kenntnis genommen: Erziehungsberechtigte", footerFont)); cell.setBorder(Rectangle.TOP); cell.setBorderWidth(1f); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100f);/*from w ww . j av a2 s. com*/ table.addCell(cell); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterHalbjahrDatumKlassenleiterLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Datum", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f); leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f);/*w w w. j av a 2 s . co m*/ centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("Klassenleiter(in)", footerFont)); rightCell.setBorder(Rectangle.TOP); rightCell.setBorderWidth(1f); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f); table.addCell(leftCell); table.addCell(centerCell); table.addCell(rightCell); table.setWidths(new float[] { 0.3f, 0.3f, 0.3f }); return table; }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void writeTitlePage() throws DocumentException { Rectangle page = myDoc.getPageSize(); PdfPTable head = new PdfPTable(1); PdfPTable colontitleTable = createColontitleTable(getProject().getProjectName(), GanttLanguage.getInstance().getMediumDateFormat().format(new Date()), getProject().getOrganization(), getProject().getWebLink()); head.setTotalWidth(page.getWidth() - myDoc.leftMargin() - myDoc.rightMargin()); {/* ww w.ja va2s .c om*/ PdfPCell cell = new PdfPCell(colontitleTable); cell.setBorder(PdfPCell.NO_BORDER); head.addCell(cell); } addEmptyRow(head, 20); LinkedHashMap<String, String> attrs = new LinkedHashMap<>(); attrs.put(i18n("label.project_manager"), buildManagerString()); attrs.put(i18n("label.dates"), buildProjectDatesString()); attrs.put(" ", " "); attrs.put(i18n("label.completion"), buildProjectCompletionString()); attrs.put(i18n("label.tasks"), String.valueOf(getProject().getTaskManager().getTaskCount())); attrs.put(i18n("label.resources"), String.valueOf(getProject().getHumanResourceManager().getResources().size())); PdfPTable attrsTable = new PdfPTable(2); writeAttributes(attrsTable, attrs); PdfPCell attrsCell = new PdfPCell(attrsTable); attrsCell.setBorder(PdfPCell.NO_BORDER); head.addCell(attrsCell); addEmptyRow(head, 20); if (getProject().getDescription().length() > 0) { Paragraph p = new Paragraph(getProject().getDescription(), getSansRegular(12)); PdfPCell cell = new PdfPCell(p); cell.setBorder(PdfPCell.TOP | PdfPCell.BOTTOM); cell.setBorderColor(SORTAVALA_GREEN); cell.setBorderWidth(1); cell.setPadding(5); cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER); head.addCell(cell); } myDoc.add(head); }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private PdfPTable createTableHeader(ColumnList tableHeader, ArrayList<Column> orderedColumns) { for (int i = 0; i < tableHeader.getSize(); i++) { Column c = tableHeader.getField(i); if (c.isVisible()) { orderedColumns.add(c);// ww w . j a v a 2 s . com } } Collections.sort(orderedColumns, new Comparator<Column>() { @Override public int compare(Column lhs, Column rhs) { if (lhs == null || rhs == null) { return 0; } return lhs.getOrder() - rhs.getOrder(); } }); float[] widths = new float[orderedColumns.size()]; for (int i = 0; i < orderedColumns.size(); i++) { Column column = orderedColumns.get(i); widths[i] = column.getWidth(); } PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(95); for (Column field : orderedColumns) { if (field.isVisible()) { PdfPCell cell = new PdfPCell(new Paragraph(field.getName(), getSansRegularBold(12f))); cell.setPaddingTop(4); cell.setPaddingBottom(4); cell.setPaddingLeft(5); cell.setPaddingRight(5); cell.setBorderWidth(0); cell.setBorder(PdfPCell.BOTTOM); cell.setBorderWidthBottom(1); cell.setBorderColor(SORTAVALA_GREEN); table.addCell(cell); } } table.setHeaderRows(1); return table; }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void addEmptyRow(PdfPTable table, float height) { PdfPCell emptyCell = new PdfPCell(new Paragraph(" ", getSansRegular(height))); emptyCell.setBorderWidth(0); for (int i = 0; i < table.getNumberOfColumns(); i++) { table.addCell(emptyCell);//w w w. j av a 2 s.c om } }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void writeProperties(ArrayList<Column> orderedColumns, Map<String, String> id2value, PdfPTable table, Map<String, PdfPCell> id2cell) { for (Column column : orderedColumns) { PdfPCell cell = id2cell.get(column.getID()); if (cell == null) { String value = id2value.get(column.getID()); if (value == null) { value = ""; }/*from w w w. j a va2s .c o m*/ Paragraph p = new Paragraph(value, getSansRegular(12)); cell = new PdfPCell(p); if (TaskDefaultColumn.COST.getStub().getID().equals(column.getID()) || ResourceDefaultColumn.STANDARD_RATE.getStub().getID().equals(column.getID()) || ResourceDefaultColumn.TOTAL_COST.getStub().getID().equals(column.getID()) || ResourceDefaultColumn.TOTAL_LOAD.getStub().getID().equals(column.getID())) { cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } cell.setBorderWidth(0); cell.setPaddingLeft(5); } table.addCell(cell); } }
From source file:org.ganttproject.impex.htmlpdf.itext.ThemeImpl.java
License:GNU General Public License
private void writeTasks() throws Exception { ColumnList visibleFields = getUIFacade().getTaskTree().getVisibleFields(); final ArrayList<Column> orderedColumns = new ArrayList<>(); final PdfPTable table = createTableHeader(visibleFields, orderedColumns); TaskVisitor taskVisitor = new TaskVisitor() { int myPreviousChildTaskCount = 0; int myPreviousChildlessTaskCount = 0; PropertyFetcher myTaskProperty = new PropertyFetcher(getProject()); @Override/*from w w w . j a v a2 s. c om*/ protected String serializeTask(Task t, int depth) throws Exception { boolean addEmptyRow = false; if (depth == 0) { addEmptyRow = myPreviousChildTaskCount > 0; boolean hasNested = getProject().getTaskManager().getTaskHierarchy().hasNestedTasks(t); if (!addEmptyRow) { if (hasNested) { addEmptyRow = myPreviousChildlessTaskCount > 0; myPreviousChildlessTaskCount = 0; } } myPreviousChildTaskCount = 0; if (!hasNested) { myPreviousChildlessTaskCount++; } } else { myPreviousChildTaskCount++; myPreviousChildlessTaskCount = 0; } if (addEmptyRow) { addEmptyRow(table, 10); } HashMap<String, String> id2value = new HashMap<>(); myTaskProperty.getTaskAttributes(t, id2value); HashMap<String, PdfPCell> id2cell = new HashMap<>(); PdfPCell nameCell; if (myShowNotesOption.isChecked() && t.getNotes() != null && !"".equals(t.getNotes())) { nameCell = new PdfPCell(createNameCellContent(t)); } else { nameCell = new PdfPCell(new Paragraph(t.getName(), getSansRegular(12))); } nameCell.setBorderWidth(0); nameCell.setPaddingLeft(5 + depth * 10); id2cell.put("tpd3", nameCell); writeProperties(orderedColumns, id2value, table, id2cell); return ""; } private PdfPTable createNameCellContent(Task t) { PdfPTable table = new PdfPTable(1); Paragraph p = new Paragraph(t.getName(), getSansRegular(12)); PdfPCell cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPhrase(p); cell1.setPaddingLeft(0); table.addCell(cell1); Paragraph notes = new Paragraph(t.getNotes(), getSansItalic(8)); PdfPCell cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPhrase(notes); cell2.setPaddingLeft(3); table.addCell(cell2); return table; } }; taskVisitor.visit(getProject().getTaskManager()); myDoc.add(table); }
From source file:PDF.PDFTrackGenerator.java
License:Open Source License
/** * Metda generateTrackPDFA4 sli na samotn vygenerovanie PDF dokumentu trasy na formt A4. * @param lineWeight - hrbka ?iary trasy na mape * @param color - farba ?iary trasy na mape * @param width - rka mapy// w w w . j a v a 2s . c o m * @param height - vka mapy * @param scale - klovacia kontanta mapy (n x rozlenie mapy) * @param startDate - dtum a ?as prvho bodu trasy * @param endDate - dtum a ?as poslednho bodu trasy * @param activity - aktivita trasy * @param user - pouvate (majite) trasy */ public void generateTrackPDFA4(int lineWeight, String color, int width, int height, int scale, String startDate, String endDate, String activity, String user) { try { Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream(path + fileName + ".pdf")); doc.open(); Font nadpisFont = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD); Font detailyFont = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL); Paragraph nadpisPar = new Paragraph(); nadpisPar.setAlignment(Element.ALIGN_CENTER); Phrase nadpis = new Phrase(fileName, nadpisFont); nadpisPar.add(nadpis); nadpisPar.add(""); doc.add(nadpisPar); doc.add(Chunk.NEWLINE); PdfPTable tabulka = new PdfPTable(2); tabulka.setWidthPercentage(100); float[] columnWidth = { 6f, 4f }; tabulka.setWidths(columnWidth); StaticMapResolver res = new StaticMapResolver(loader); String mapUrl = res.getStaticMapTrackURLWithMultimedia(lineWeight, color, width, height, scale); Image img = Image.getInstance(new URL(mapUrl)); //img.scalePercent(50); PdfPCell riadokSObr = new PdfPCell(img, true); riadokSObr.setBorder(Rectangle.NO_BORDER); riadokSObr.setPaddingBottom(10f); PdfPCell riadokSText = new PdfPCell(new Phrase("Description: " + loader.getTrackDescription() + "\n\n\nTrack activity: " + activity.substring(4) + "\n\n\nStart place: " + loader.getStartAddress() + "\n\n\nEnd Place: " + loader.getEndAddress() + "\n\n\nTrack length: " + loader.getLength() + " km\n\n\nMin elevation: " + loader.getMinElevation() + " m\n\n\nMax elevation: " + loader.getMaxElevation() + " m\n\n\nHeight difference: " + loader.getHeightDiff() + " m\n\n\nStart: " + startDate + "\n\n\nEnd: " + endDate + "\n\n\nDuration: " + loader.getDuration(), detailyFont)); riadokSText.setBorder(Rectangle.NO_BORDER); riadokSText.setPaddingLeft(20f); riadokSText.setPaddingTop(5f); riadokSText.setPaddingBottom(10f); tabulka.addCell(riadokSObr); tabulka.addCell(riadokSText); doc.add(tabulka); //doc.add(new Phrase("\n", detailyFont)); PdfPTable obrTabulka = new PdfPTable(3); obrTabulka.setWidthPercentage(100); ArrayList<String> goodFiles = new ArrayList<String>(); for (int i = 0; i < loader.getMultimediaFiles().size(); i++) { if (!loader.getMultimediaFiles().get(i).getPath().startsWith("YTB")) { String extension = loader.getMultimediaFiles().get(i).getPath().substring( loader.getMultimediaFiles().get(i).getPath().lastIndexOf("."), loader.getMultimediaFiles().get(i).getPath().length()); String newPath = loader.getMultimediaFiles().get(i).getPath().substring(0, loader.getMultimediaFiles().get(i).getPath().lastIndexOf(".")) + "_THUMB" + extension; goodFiles.add(newPath); } } if (!goodFiles.isEmpty()) { int freeCount = 9; if (goodFiles.size() <= 9) { for (int i = 0; i < goodFiles.size(); i++) { Image tempImg = Image.getInstance(goodFiles.get(i)); tempImg.scalePercent(10f); PdfPCell tempCell = new PdfPCell(tempImg, true); tempCell.setPadding(3f); //tempCell.setPaddingTop(5f); tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE); tempCell.setHorizontalAlignment(Element.ALIGN_CENTER); tempCell.setFixedHeight(130f); tempCell.setBackgroundColor(BaseColor.BLACK); tempCell.setBorderColor(BaseColor.WHITE); tempCell.setBorderWidth(4f); //tempCell.setBorder(Rectangle.NO_BORDER); obrTabulka.addCell(tempCell); } for (int i = 0; i < 9 - goodFiles.size(); i++) { PdfPCell tempCell = new PdfPCell(); tempCell.setBorder(Rectangle.NO_BORDER); obrTabulka.addCell(tempCell); } } else if (goodFiles.size() <= 18) { for (int i = 0; i < 9; i++) { Image tempImg = Image.getInstance(goodFiles.get(i)); tempImg.scalePercent(10f); PdfPCell tempCell = new PdfPCell(tempImg, true); tempCell.setPadding(3f); //tempCell.setPaddingTop(5f); tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE); tempCell.setHorizontalAlignment(Element.ALIGN_CENTER); tempCell.setFixedHeight(130f); tempCell.setBackgroundColor(BaseColor.BLACK); tempCell.setBorderColor(BaseColor.WHITE); tempCell.setBorderWidth(4f); //tempCell.setBorder(Rectangle.NO_BORDER); obrTabulka.addCell(tempCell); } } else { for (int i = 0; i < (goodFiles.size() % 9); i++) { goodFiles.remove(goodFiles.size() - 1 - i); } int counting = (goodFiles.size() / 9); for (int i = 0; i < goodFiles.size(); i = i + counting) { Image tempImg = Image.getInstance(goodFiles.get(i)); tempImg.scalePercent(10f); PdfPCell tempCell = new PdfPCell(tempImg, true); tempCell.setPadding(3f); //tempCell.setPaddingTop(5f); tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE); tempCell.setHorizontalAlignment(Element.ALIGN_CENTER); tempCell.setFixedHeight(130f); tempCell.setBackgroundColor(BaseColor.BLACK); tempCell.setBorderColor(BaseColor.WHITE); tempCell.setBorderWidth(4f); //tempCell.setBorder(Rectangle.NO_BORDER); obrTabulka.addCell(tempCell); freeCount--; } for (int i = 0; i < freeCount; i++) { PdfPCell tempCell = new PdfPCell(); tempCell.setBorder(Rectangle.NO_BORDER); obrTabulka.addCell(tempCell); } } } doc.add(obrTabulka); Font lastFont = new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC); Phrase lastText = new Phrase("This PDF document was generated by gTrax app for user " + user, lastFont); doc.add(lastText); doc.close(); } catch (Exception ex) { FileLogger.getInstance() .createNewLog("ERROR: Cannot CREATE PDF for track " + fileName + " for user " + user + " !!!"); System.out.println("pruser"); } }
From source file:pipe.PdfMaker.java
/** * Builds and returns the main table.// ww w. jav a 2s .c o m * * @return */ Element mainElement(ArrayList values) throws BadElementException { PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100f); table.getDefaultCell().setBorderWidth(0.5f); Element element; PdfPCell cell; element = this.firstElement((String) values.get(0)); cell = this.createCell(1, 1); cell.setBorder(15); cell.setPadding(2f); cell.addElement(element); table.addCell(cell); String dirString = "pictures" + File.separator + (String) values.get(0) + "_" + (String) values.get(1) + "_" + (String) values.get(2) + File.separator + "01.jpg"; element = this.fourthLogoElement(dirString); // You need to pass the image to the constructor. // If you add the image, it will be stretched to fill the cell. cell = new PdfPCell((Image) element); cell.setPadding(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(0.3f); cell.setRowspan(4); table.addCell(cell); element = this.thirdElement((String) values.get(1), (String) values.get(2)); cell = this.createCell(1, 1); cell.addElement(element); table.addCell(cell); element = this.fifthElement((String) values.get(3), (String) values.get(4), (String) values.get(5)); cell = this.createCell(1, 1); cell.addElement(element); table.addCell(cell); element = this.sixthElement((String) values.get(6), (String) values.get(7)); cell = this.createCell(1, 1); cell.addElement(element); cell.setBorderWidth(0.3f); table.addCell(cell); element = this.seventhElement((String) values.get(8), (String) values.get(9)); cell = this.createCell(1, 1); cell.addElement(element); table.addCell(cell); element = this.eightthElement((String) values.get(10), (String) values.get(11)); cell = this.createCell(2, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.ninethElement((String) values.get(12), (String) values.get(13), (String) values.get(14)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.tenthElement((String) values.get(15), (String) values.get(16), (String) values.get(17)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.eleventhElement((String) values.get(18), (String) values.get(19), (String) values.get(20)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.twelvethElement((String) values.get(21), (String) values.get(22), (String) values.get(23)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.thirteenthElement((String) values.get(24), (String) values.get(25)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.fourteenthElement((String) values.get(26), (String) values.get(27)); cell = this.createCell(1, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); element = this.fifteenthElement((String) values.get(28)); cell = this.createCell(2, 1); cell.setBorderWidth(0.3f); cell.addElement(element); table.addCell(cell); return table; }