List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingTop
public void setPaddingTop(float paddingTop)
From source file:ro.nextreports.engine.exporter.PdfExporter.java
License:Apache License
private PdfPCell renderPdfCell(BandElement bandElement, Object value, int gridRow, int rowSpan, int colSpan, boolean image, int column) { Map<String, Object> style = buildCellStyleMap(bandElement, value, gridRow, column, colSpan); FontFactoryImp fact = new FontFactoryImp(); com.itextpdf.text.Font fnt;// w w w .ja v a2 s . c o m if (bandElement != null) { fontName = (String) style.get(StyleFormatConstants.FONT_NAME_KEY); int size = ((Float) style.get(StyleFormatConstants.FONT_SIZE)).intValue(); fnt = getFont(size); } else { fnt = getFont(10); } PdfPCell cell; if (image) { if (value == null) { cell = new PdfPCell(new Phrase(IMAGE_NOT_FOUND)); } else { ImageBandElement ibe = (ImageBandElement) bandElement; try { byte[] imageBytes = getImage((String) value); cell = getImageCell(ibe, imageBytes, column, colSpan); } catch (Exception e) { cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED)); } } } else if (bandElement instanceof HyperlinkBandElement) { Hyperlink hyperlink = ((HyperlinkBandElement) bandElement).getHyperlink(); Anchor anchor = new Anchor(hyperlink.getText(), fnt); anchor.setReference(hyperlink.getUrl()); Phrase ph = new Phrase(); ph.add(anchor); cell = new PdfPCell(ph); } else if (bandElement instanceof ReportBandElement) { Report report = ((ReportBandElement) bandElement).getReport(); ExporterBean eb = null; try { eb = getSubreportExporterBean(report); PdfExporter subExporter = new PdfExporter(eb); subExporter.export(); PdfPTable innerTable = subExporter.getTable(); cell = new PdfPCell(innerTable); } catch (Exception e) { cell = new PdfPCell(); e.printStackTrace(); } finally { if ((eb != null) && (eb.getResult() != null)) { eb.getResult().close(); } } } else if ((bandElement instanceof VariableBandElement) && (VariableFactory .getVariable(((VariableBandElement) bandElement).getVariable()) instanceof TotalPageNoVariable)) { try { cell = new PdfPCell(Image.getInstance(total)); } catch (BadElementException e) { cell = new PdfPCell(new Phrase("NA")); } } else if (bandElement instanceof ImageColumnBandElement) { try { String v = StringUtil.getValueAsString(value, null); if (StringUtil.BLOB.equals(v)) { cell = new PdfPCell(new Phrase(StringUtil.BLOB)); } else { byte[] bytes = StringUtil.decodeImage(v); cell = getImageCell(bandElement, bytes, column, colSpan); } } catch (Exception e) { e.printStackTrace(); cell = new PdfPCell(new Phrase(IMAGE_NOT_LOADED)); } } else { String stringValue; if (style.containsKey(StyleFormatConstants.PATTERN)) { stringValue = StringUtil.getValueAsString(value, (String) style.get(StyleFormatConstants.PATTERN), getReportLanguage()); } else { stringValue = StringUtil.getValueAsString(value, null, getReportLanguage()); } if (stringValue == null) { stringValue = ""; } if (stringValue.startsWith("<html>")) { StringReader reader = new StringReader(stringValue); List<Element> elems = new ArrayList<Element>(); try { elems = HTMLWorker.parseToList(reader, new StyleSheet()); Phrase ph = new Phrase(); for (int i = 0; i < elems.size(); i++) { Element elem = (Element) elems.get(i); ph.add(elem); } cell = new PdfPCell(ph); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Phrase ph = new Phrase(stringValue, fnt); cell = new PdfPCell(ph); } } else { Phrase ph = new Phrase(stringValue, fnt); cell = new PdfPCell(ph); } } cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setUseDescender(true); // needed for a cell without padding cell.setMinimumHeight(MINIMUM_HEIGHT); // needed if there is a row in which all cells are empty if (bandElement != null) { cell.setRotation(bandElement.getTextRotation()); } if (colSpan > 1) { cell.setColspan(colSpan); } if (rowSpan > 1) { cell.setRowspan(rowSpan); } if (style != null) { updateFont(style, fnt); if (style.containsKey(StyleFormatConstants.BACKGROUND_COLOR)) { Color val = (Color) style.get(StyleFormatConstants.BACKGROUND_COLOR); cell.setBackgroundColor(new BaseColor(val)); } if (style.containsKey(StyleFormatConstants.HORIZONTAL_ALIGN_KEY)) { if (StyleFormatConstants.HORIZONTAL_ALIGN_LEFT .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) { cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); } if (StyleFormatConstants.HORIZONTAL_ALIGN_RIGHT .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) { cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } if (StyleFormatConstants.HORIZONTAL_ALIGN_CENTER .equals(style.get(StyleFormatConstants.HORIZONTAL_ALIGN_KEY))) { cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); } } if (style.containsKey(StyleFormatConstants.VERTICAL_ALIGN_KEY)) { if (StyleFormatConstants.VERTICAL_ALIGN_TOP .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) { cell.setVerticalAlignment(Element.ALIGN_TOP); } if (StyleFormatConstants.VERTICAL_ALIGN_MIDDLE .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) { cell.setVerticalAlignment(Element.ALIGN_MIDDLE); } if (StyleFormatConstants.VERTICAL_ALIGN_BOTTOM .equals(style.get(StyleFormatConstants.VERTICAL_ALIGN_KEY))) { cell.setVerticalAlignment(Element.ALIGN_BOTTOM); } } if (style.containsKey(StyleFormatConstants.PADDING_LEFT)) { Float val = (Float) style.get(StyleFormatConstants.PADDING_LEFT); cell.setPaddingLeft(val); } if (style.containsKey(StyleFormatConstants.PADDING_RIGHT)) { Float val = (Float) style.get(StyleFormatConstants.PADDING_RIGHT); cell.setPaddingRight(val); } if (style.containsKey(StyleFormatConstants.PADDING_TOP)) { Float val = (Float) style.get(StyleFormatConstants.PADDING_TOP); cell.setPaddingTop(val); } if (style.containsKey(StyleFormatConstants.PADDING_BOTTOM)) { Float val = (Float) style.get(StyleFormatConstants.PADDING_BOTTOM); cell.setPaddingBottom(val); } cell.setBorderWidth(0); if (style.containsKey(StyleFormatConstants.BORDER_LEFT)) { Float val = (Float) style.get(StyleFormatConstants.BORDER_LEFT); cell.setBorderWidthLeft(val / 2); Color color = (Color) style.get(StyleFormatConstants.BORDER_LEFT_COLOR); cell.setBorderColorLeft(new BaseColor(color)); } if (style.containsKey(StyleFormatConstants.BORDER_RIGHT)) { Float val = (Float) style.get(StyleFormatConstants.BORDER_RIGHT); cell.setBorderWidthRight(val / 2); Color color = (Color) style.get(StyleFormatConstants.BORDER_RIGHT_COLOR); cell.setBorderColorRight(new BaseColor(color)); } if (style.containsKey(StyleFormatConstants.BORDER_TOP)) { Float val = (Float) style.get(StyleFormatConstants.BORDER_TOP); cell.setBorderWidthTop(val / 2); Color color = (Color) style.get(StyleFormatConstants.BORDER_TOP_COLOR); cell.setBorderColorTop(new BaseColor(color)); } if (style.containsKey(StyleFormatConstants.BORDER_BOTTOM)) { Float val = (Float) style.get(StyleFormatConstants.BORDER_BOTTOM); cell.setBorderWidthBottom(val / 2); Color color = (Color) style.get(StyleFormatConstants.BORDER_BOTTOM_COLOR); cell.setBorderColorBottom(new BaseColor(color)); } // for subreports we use default no wrap if (cell.getTable() == null) { cell.setNoWrap(true); if (bandElement != null) { if (bandElement.isWrapText()) { cell.setNoWrap(false); } } } // to see a background image all cells must not have any background! if (bean.getReportLayout().getBackgroundImage() != null) { cell.setBackgroundColor(null); } } return cell; }
From source file:se.billes.pdf.renderer.model.text.TableParagraph.java
License:Open Source License
@Override public void onRender(PdfPCell cell) throws PdfRenderException { PdfPTable table = new PdfPTable(widths.length); try {/* w ww . j ava 2 s . c o m*/ table.setTotalWidth(getTotalWidthsAsPs()); table.setLockedWidth(true); table.setSpacingAfter(0f); for (AbstractParagraph tableCell : cells) { PdfPCell c = new PdfPCell(); float[] padding = new float[] { 0f, 0f, 0f, 0f }; if (tableCell instanceof TableCell) { padding = ((TableCell) tableCell).getPadding(); } c.setBorderWidth(0f); c.setLeft(0); c.setTop(0); c.setRight(0); c.setBottom(0); c.setUseAscender(true); c.setIndent(0); c.setHorizontalAlignment(Element.ALIGN_LEFT); c.setVerticalAlignment(Element.ALIGN_TOP); c.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(padding[0])); c.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(padding[3])); c.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(padding[2])); c.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(padding[1])); c.setBorder(0); tableCell.onRender(c); table.addCell(c); } cell.addElement(table); } catch (Exception e) { throw new PdfRenderException(e); } }
From source file:se.billes.pdf.renderer.request.factory.CellFactory.java
License:Open Source License
public PdfPCell createCell(Block block) { float[] margins = block.getMargins(); PdfPCell cell = new PdfPCell(); cell.setBorderWidth(0);//from w ww . ja v a 2 s . c o m cell.setVerticalAlignment(VerticalAlign.getByName(block.getVerticalAlign()).getAlignment()); cell.setLeft(0); cell.setTop(0); cell.setRight(0); cell.setBottom(0); cell.setUseAscender(block.isUseAscender()); cell.setIndent(0); cell.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(margins[0])); cell.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(margins[3])); cell.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(margins[1])); cell.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(margins[2])); cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints(block.getPosition()[3])); cell.setBorder(0); cell.setCellEvent(new CellBlockEvent().createEvent(block)); cell.setRotation(block.getRotation()); return cell; }
From source file:se.billes.pdf.renderer.request.factory.CellFactory.java
License:Open Source License
public PdfPCell getFillCell() { PdfPCell fillCell = new PdfPCell(); fillCell.setBorderWidth(0f);//from w w w. j av a2s . c o m fillCell.setLeft(0); fillCell.setTop(0); fillCell.setRight(0); fillCell.setBottom(0); fillCell.setUseAscender(true); fillCell.setIndent(0); fillCell.setHorizontalAlignment(Element.ALIGN_LEFT); fillCell.setVerticalAlignment(Element.ALIGN_BOTTOM); fillCell.setPaddingLeft(0f); fillCell.setPaddingBottom(0f); fillCell.setPaddingRight(0f); fillCell.setPaddingTop(0f); fillCell.setBorder(0); renderEmptyCell(fillCell); return fillCell; }
From source file:utils.pdf.cv_templates.Template1.java
private void addPersonalInformation(User user) throws DocumentException { Paragraph paragraph;//from www . j a va2 s.co m PdfPCell cell; PdfPTable table; table = new PdfPTable(new float[] { 0.5f, 2f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.name + " " + user.surnames, font1); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.birthDate + "\n", font4); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph("Calle " + user.residenceAddress + " N " + user.residenceNumber + " " + user.residenceZipCode + " " + user.residenceCity + "\n", font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.phoneNumber, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.email, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); document.add(table); }
From source file:utils.pdf.cv_templates.Template1.java
private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException { Paragraph paragraph;//from w ww.ja v a 2 s . c om PdfPCell cell; PdfPTable table; for (int i = 0; i < experienceList.size(); i++) { table = new PdfPTable(new float[] { 1f, 0.5f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); if (i == 0) { paragraph = new Paragraph("Experiencia Profesional", font1); cell.setBorder(PdfPCell.NO_BORDER); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).job + "." + " " + experienceList.get(i).company, font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).startDate + " - " + experienceList.get(i).endDate, font3); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template2.java
private void addPersonalInformation(User user) throws DocumentException { Paragraph paragraph;//from w w w . j a va 2 s . c o m PdfPCell cell; PdfPTable table; table = new PdfPTable(new float[] { 0.5f, 2f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.name.toUpperCase() + " " + user.surnames.toUpperCase(), font1); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.birthDate + "\n", font2); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.phoneNumber, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); paragraph = new Paragraph(user.email, font2); paragraph.setSpacingBefore(20); cell.setBorder(PdfPCell.NO_BORDER); cell.addElement(paragraph); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(" "); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(55); cell.setPaddingTop(0); if (!user.drivingLicense.equals("No tengo carnet")) { paragraph = new Paragraph("\nPermiso de conducir: " + user.drivingLicense, font2); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); } table.addCell(cell); document.add(table); }
From source file:utils.pdf.cv_templates.Template2.java
private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException { Paragraph paragraph;//from w ww. j a v a 2 s . c o m PdfPCell cell; PdfPTable table; for (int i = 0; i < experienceList.size(); i++) { table = new PdfPTable(new float[] { 1f, 0.5f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); if (i == 0) { paragraph = new Paragraph("Practicas: ", font5); cell.setBorder(PdfPCell.NO_BORDER); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).job + "." + " " + experienceList.get(i).company, font6); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).startDate + " - " + experienceList.get(i).endDate, font6); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template2.java
private void addStudies(User user) throws DocumentException { Paragraph paragraph;// w ww . j av a2s .c o m PdfPCell cell; PdfPTable table; if (!user.studyTitle.equals("")) { table = new PdfPTable(new float[] { 1f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.studyTitle + ".", font4); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.setPaddingLeft(35); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.studyLocation, font6); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template3.java
private void addPersonalInformation(User user) throws DocumentException, IOException { Paragraph paragraph;/*from w ww.j a v a 2 s.c om*/ PdfPCell cell; PdfPTable table; Image photo_img; if (!user.photo.id.equals("")) { photo_img = Image .getInstance(String.format("https://s3.amazonaws.com/aunclickdelempleo2/" + user.photo.id)); } else { photo_img = Image.getInstance(String.format("public/images/orientation/photo/ic_profile.png")); } table = new PdfPTable(new float[] { 3, 7 }); table.setWidthPercentage(100); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingRight(15); cell.setPaddingLeft(50); cell.setPaddingTop(30); photo_img.setBorder(Image.BOX); photo_img.setBorderColor(BaseColor.WHITE); photo_img.scaleToFit(1000, 115); cell.addElement(photo_img); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(55); cell.setPaddingTop(19); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("Datos Personales", font1); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); paragraph = new Paragraph(user.name + " " + user.surnames, font2); paragraph.setAlignment(paragraph.ALIGN_LEFT); paragraph.setSpacingBefore(8); cell.addElement(paragraph); paragraph = new Paragraph(user.birthDate, font3); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); paragraph = new Paragraph("Calle " + user.residenceAddress + ", N " + user.residenceNumber + ", Ciudad " + user.residenceCity, font3); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); paragraph = new Paragraph("Telfono: " + user.phoneNumber, font3); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); paragraph = new Paragraph(user.email, font3); paragraph.setAlignment(paragraph.ALIGN_LEFT); cell.addElement(paragraph); if (!user.drivingLicense.equals("No tengo carnet")) { paragraph = new Paragraph("Permiso de conducir: " + user.drivingLicense, font3); paragraph.setAlignment(paragraph.ALIGN_LEFT); paragraph.setSpacingBefore(10); cell.addElement(paragraph); } table.addCell(cell); document.add(table); }