List of usage examples for com.lowagie.text.pdf PdfPCell setHorizontalAlignment
public void setHorizontalAlignment(int horizontalAlignment)
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFCarnet(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan, Color color) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, color))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);/*from w w w . java 2s . com*/ celda.setBorderWidth(0); celda.setBorderWidthBottom(borde); celda.setPadding(0); celda.setPaddingBottom(padding); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, Color color) {/* w w w. j ava2 s . co m*/ PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde); celda.setBackgroundColor(color); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, Color color, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo))); celda.setHorizontalAlignment(alineacion); celda.setPadding(padding);//from ww w.ja v a2s . c o m celda.setColspan(colspan); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde); celda.setBackgroundColor(color); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo))); celda.setHorizontalAlignment(alineacion); celda.setPadding(padding);//w ww .j a v a 2 s. c om celda.setColspan(colspan); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde); return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDF(PdfPTable tabla, int alineacion, int borde) { PdfPCell celda = new PdfPCell(tabla); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.LIGHT_GRAY); celda.setBorderWidth(borde);//from www. j a v a 2s . c o m return celda; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setLogo(String logo, int ancho, int alto, int alineacion) { PdfPCell celdaImg = null; try {//from www. j a v a2 s. com Image imagelogo = Image.getInstance(logo); imagelogo.scaleAbsolute(ancho, alto); celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setHorizontalAlignment(alineacion); celdaImg.setPadding(0); } catch (Exception e) { celdaImg = null; } return celdaImg; }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setBarCode(Image logo) { PdfPCell celdaImg = null; try {//w w w . j ava 2 s . c o m Image imagelogo = Image.getInstance(logo); celdaImg = new PdfPCell(imagelogo); celdaImg.setBorderWidth(0); celdaImg.setPadding(5); celdaImg.setHorizontalAlignment(Element.ALIGN_CENTER); } catch (Exception e) { celdaImg = null; } return celdaImg; }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
public void buildPDF(MimeMessage message, String replyURL, OutputStream pdfStream) throws DocumentException, MessagingException, IOException { Document document = createDocument(); PdfWriter pdfWriter = createPdfWriter(document, pdfStream); document.open();// w ww . j a v a 2s. co m String[] froms = null; try { froms = EmailAddressUtils.addressesToStrings(message.getFrom(), true /* mime decode */); } catch (MessagingException e) { logger.warn("From address is not a valid email address."); } if (froms != null) { for (String from : froms) { document.addAuthor(from); } } String subject = null; try { subject = message.getSubject(); } catch (MessagingException e) { logger.error("Error getting subject.", e); } if (subject != null) { document.addSubject(subject); document.addTitle(subject); } String[] tos = null; try { tos = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.TO), true /* mime decode */); } catch (MessagingException e) { logger.warn("To is not a valid email address."); } String[] ccs = null; try { ccs = EmailAddressUtils.addressesToStrings(message.getRecipients(RecipientType.CC), true /* mime decode */); } catch (MessagingException e) { logger.warn("CC is not a valid email address."); } Date sentDate = null; try { sentDate = message.getSentDate(); } catch (MessagingException e) { logger.error("Error getting sent date.", e); } Collection<Part> attachments = new LinkedList<Part>(); String body = BodyPartUtils.getPlainBodyAndAttachments(message, attachments); attachments = preprocessAttachments(attachments); if (body == null) { body = MISSING_BODY; } /* * PDF does not have tab support so we convert tabs to spaces */ body = StringReplaceUtils.replaceTabsWithSpaces(body, tabWidth); PdfPTable headerTable = new PdfPTable(2); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); headerTable.setWidthPercentage(100); headerTable.setWidths(new int[] { 1, 6 }); headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Font headerFont = createHeaderFont(); FontSelector headerFontSelector = createHeaderFontSelector(); PdfPCell cell = new PdfPCell(new Paragraph("From:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); String decodedFroms = StringUtils.defaultString(StringUtils.join(froms, ", ")); headerTable.addCell(headerFontSelector.process(decodedFroms)); cell = new PdfPCell(new Paragraph("To:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(tos, ", ")))); cell = new PdfPCell(new Paragraph("CC:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(StringUtils.join(ccs, ", ")))); cell = new PdfPCell(new Paragraph("Subject:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(headerFontSelector.process(StringUtils.defaultString(subject))); cell = new PdfPCell(new Paragraph("Date:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable.addCell(ObjectUtils.toString(sentDate)); cell = new PdfPCell(new Paragraph("Attachments:", headerFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(cell); headerTable .addCell(headerFontSelector.process(StringUtils.defaultString(getAttachmentHeader(attachments)))); document.add(headerTable); if (replyURL != null) { addReplyLink(document, replyURL); } /* * Body table will contain the body of the message */ PdfPTable bodyTable = new PdfPTable(1); bodyTable.setWidthPercentage(100f); bodyTable.setSplitLate(false); bodyTable.setSpacingBefore(15f); bodyTable.setHorizontalAlignment(Element.ALIGN_LEFT); addBodyAndAttachments(pdfWriter, document, bodyTable, body, attachments); Phrase footer = new Phrase(FOOTER_TEXT); PdfContentByte cb = pdfWriter.getDirectContent(); ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, footer, document.right(), document.bottom(), 0); document.close(); }
From source file:net.bull.javamelody.internal.web.pdf.PdfAbstractTableReport.java
License:Apache License
void initTable(List<String> headers, int[] relativeWidths) throws DocumentException { assert headers.size() == relativeWidths.length; final PdfPTable mytable = new PdfPTable(headers.size()); mytable.setWidthPercentage(100);/*from w w w .ja v a 2 s . co m*/ mytable.setWidths(relativeWidths); mytable.setHeaderRows(1); final PdfPCell defaultCell = mytable.getDefaultCell(); defaultCell.setGrayFill(0.9f); defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER); defaultCell.setPaddingLeft(0); defaultCell.setPaddingRight(0); final Font tableHeaderFont = PdfFonts.TABLE_HEADER.getFont(); for (final String header : headers) { mytable.addCell(new Phrase(header, tableHeaderFont)); } defaultCell.setPaddingLeft(2); defaultCell.setPaddingRight(2); this.table = mytable; }
From source file:net.bull.javamelody.internal.web.pdf.PdfCacheInformationsReport.java
License:Apache License
private void writeCacheInformations(CacheInformations cacheInformations) { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(cacheInformations.getName()); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); if (configurationEnabled) { addCell(integerFormat.format(cacheInformations.getInMemoryPercentUsed())); }//from w w w.j a v a2 s .c o m addCell(integerFormat.format(cacheInformations.getInMemoryObjectCount())); addCell(integerFormat.format(cacheInformations.getOnDiskObjectCount())); if (hitsRatioEnabled) { addCell(integerFormat.format(cacheInformations.getInMemoryHitsRatio())); addCell(integerFormat.format(cacheInformations.getHitsRatio())); } if (configurationEnabled) { defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); addCell(cacheInformations.getConfiguration()); } }