List of usage examples for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment
public void setHorizontalAlignment(int horizontalAlignment)
From source file:org.cidte.sii.negocio.PDFWriter.java
private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); // set the cell alignment cell.setHorizontalAlignment(align); // some padding cell.setPaddingLeft(10);// ww w .j a v a2 s . c o m // set the cell column span in case you want to merge two or more cells cell.setColspan(colspan); // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } // add the call to the table table.addCell(cell); }
From source file:org.displaytag.sample.decorators.ItextTotalWrapper.java
License:Open Source License
/** * Obtain a cell with the given value./*from ww w .j a v a 2s. c o m*/ * @param value Value to display in the cell. * @return A cell with the given value. */ private PdfPCell getCell(String value) { PdfPCell cell = new PdfPCell(new Phrase(new Chunk(value, this.font))); cell.setLeading(8, 0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); return cell; }
From source file:org.dspace.disseminate.CitationDocument.java
/** * Takes a DSpace {@link Bitstream} and uses its associated METADATA to * create a cover page.//w w w . j a va 2 s. com * * @param cDoc The cover page document to add cited information to. * @param writer * @param cMeta * METADATA retrieved from the parent collection. * @throws IOException * @throws DocumentException */ private void generateCoverPage(Document cDoc, PdfWriter writer, CitationMeta cMeta) throws DocumentException { cDoc.open(); writer.setCompressionLevel(0); Item item = cMeta.getItem(); //Set up some fonts Font helv26 = FontFactory.getFont(FontFactory.HELVETICA, 26f, BaseColor.BLACK); Font helv16 = FontFactory.getFont(FontFactory.HELVETICA, 16f, BaseColor.BLACK); Font helv12 = FontFactory.getFont(FontFactory.HELVETICA, 12f, BaseColor.BLACK); Font helv12_italic = FontFactory.getFont(FontFactory.HELVETICA_OBLIQUE, 12f, BaseColor.BLACK); Font helv11_bold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11f, BaseColor.BLACK); Font helv9 = FontFactory.getFont(FontFactory.HELVETICA, 9f, BaseColor.BLACK); // 1 - Header: // University Name // Repository Name repository.url Paragraph university = new Paragraph("The Ohio State University", helv11_bold); cDoc.add(university); PdfPTable repositoryTable = new PdfPTable(2); repositoryTable.setWidthPercentage(100); Chunk repositoryName = new Chunk("Knowledge Bank", helv11_bold); PdfPCell nameCell = new PdfPCell(); nameCell.setBorderWidth(0); nameCell.addElement(repositoryName); Chunk repositoryURL = new Chunk("kb.osu.edu", helv11_bold); repositoryURL.setAnchor("http://kb.osu.edu"); PdfPCell urlCell = new PdfPCell(); urlCell.setHorizontalAlignment(Element.ALIGN_RIGHT); urlCell.setBorderWidth(0); urlCell.addElement(repositoryURL); repositoryTable.addCell(nameCell); repositoryTable.addCell(urlCell); repositoryTable.setSpacingAfter(5); cDoc.add(repositoryTable); // Line Separator LineSeparator lineSeparator = new LineSeparator(); cDoc.add(lineSeparator); // 2 - Bread Crumbs // Community Name Collection Name PdfPTable breadcrumbTable = new PdfPTable(2); breadcrumbTable.setWidthPercentage(100); Chunk communityName = new Chunk(getOwningCommunity(item), helv9); PdfPCell commCell = new PdfPCell(); commCell.setBorderWidth(0); commCell.addElement(communityName); Chunk collectionName = new Chunk(getOwningCollection(item), helv9); PdfPCell collCell = new PdfPCell(); collCell.setHorizontalAlignment(Element.ALIGN_RIGHT); collCell.setBorderWidth(0); collCell.addElement(collectionName); breadcrumbTable.addCell(commCell); breadcrumbTable.addCell(collCell); breadcrumbTable.setSpacingBefore(5); breadcrumbTable.setSpacingAfter(5); cDoc.add(breadcrumbTable); // Line Separator cDoc.add(lineSeparator); // 3 - Metadata // date.issued // dc.title // dc.creator; dc.creator Paragraph dateIssued = new Paragraph(getFirstMetadata(item, "dc.date.issued"), helv12); dateIssued.setSpacingBefore(20); cDoc.add(dateIssued); Paragraph title = new Paragraph(item.getName(), helv26); title.setSpacingBefore(15); cDoc.add(title); Paragraph creators = new Paragraph(getAllMetadataSeperated(item, "dc.creator"), helv16); creators.setSpacingBefore(30); creators.setSpacingAfter(20); cDoc.add(creators); // Line Separator cDoc.add(lineSeparator); // 4 - Citation // dc.identifier.citation // dc.identifier.uri Paragraph citation = new Paragraph(getFirstMetadata(item, "dc.identifier.citation"), helv12); Chunk identifierChunk = new Chunk(getFirstMetadata(item, "dc.identifier.uri"), helv12); identifierChunk.setAnchor(getFirstMetadata(item, "dc.identifier.uri")); Paragraph identifier = new Paragraph(); identifier.add(identifierChunk); cDoc.add(citation); cDoc.add(identifier); // 5 - License // Downloaded from the Knowledge Bank, The Ohio State University's institutional repository Paragraph license = new Paragraph( "Downloaded from the Knowledge Bank, The Ohio State University's institutional repository", helv12_italic); license.setSpacingBefore(10); cDoc.add(license); cDoc.close(); }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterDienstsiegelLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("", footerFont)); leftCell.setBorder(Rectangle.NO_BORDER); leftCell.setBorderWidth(1f);/*from w w w.j av a 2 s. c o m*/ PdfPCell centerCell = new PdfPCell(new Phrase("Dienstsiegel der Schule", footerFont)); centerCell.setBorder(Rectangle.NO_BORDER); centerCell.setBorderWidth(1f); centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont)); rightCell.setBorder(Rectangle.NO_BORDER); rightCell.setBorderWidth(1f); PdfPTable table = new PdfPTable(3); table.setHorizontalAlignment(Element.ALIGN_MIDDLE); 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 buildFooterUnterschriftenLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Schulleiter(in)", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f);/* w ww.ja v a 2s . com*/ leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f); 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);//from w w w .ja va 2 s . com cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100f); table.addCell(cell); return table; }
From source file:org.fossa.rolp.util.PdfFormatHelper.java
License:Open Source License
public static PdfPTable buildFooterHalbjahrDatumLine(String datumString, Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase(datumString, footerFont)); leftCell.setBorder(Rectangle.NO_BORDER); leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.NO_BORDER); centerCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell rightCell = new PdfPCell(new Phrase("", footerFont)); rightCell.setBorder(Rectangle.NO_BORDER); rightCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100f);/*w ww . java2 s .c om*/ 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 buildFooterHalbjahrDatumKlassenleiterLine(Font footerFont) throws DocumentException { PdfPCell leftCell = new PdfPCell(new Phrase("Datum", footerFont)); leftCell.setBorder(Rectangle.TOP); leftCell.setBorderWidth(1f);/* w w w. j ava 2s. com*/ leftCell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell centerCell = new PdfPCell(new Phrase("", footerFont)); centerCell.setBorder(Rectangle.TOP); centerCell.setBorderWidth(1f); 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 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 = ""; }//w w w.j av a2s . com 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 PdfPTable createColontitleTable(String topLeft, String topRight, String bottomLeft, String bottomRight) {/*from w ww. j a v a 2 s.c o m*/ PdfPTable head = new PdfPTable(2); { PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); Paragraph p = new Paragraph(topLeft, getSansRegularBold(18)); p.setAlignment(Paragraph.ALIGN_LEFT); // colontitle.setLeading(0); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); // cell.setPaddingLeft(2); cell.setPaddingBottom(6); cell.setPhrase(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); Paragraph p = new Paragraph(topRight, getSansRegularBold(10)); p.setAlignment(Paragraph.ALIGN_RIGHT); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setPaddingBottom(6); cell.setPhrase(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setPaddingLeft(3); cell.setPaddingTop(2); cell.setPaddingBottom(6); cell.setBorder(Rectangle.TOP); cell.setBorderWidthTop(2); cell.setBorderColor(SORTAVALA_GREEN); Paragraph p = new Paragraph(bottomLeft, getSansRegularBold(18)); p.setAlignment(Paragraph.ALIGN_LEFT); p.setExtraParagraphSpace(0); p.setIndentationLeft(0); p.setSpacingBefore(0); cell.setPhrase(p); // cell.addElement(p); head.addCell(cell); } { PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingTop(2); cell.setPaddingBottom(6); cell.setBorder(Rectangle.TOP); cell.setBorderWidthTop(2); cell.setBorderColor(SORTAVALA_GREEN); Paragraph p = new Paragraph(bottomRight, getSansRegularBold(10)); p.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPhrase(p); head.addCell(cell); } final Document document = myDoc; Rectangle page = document.getPageSize(); head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin()); return head; }