List of usage examples for com.itextpdf.text.pdf PdfPCell setPadding
public void setPadding(float padding)
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void reporteinventario(Map<String, Object> model, HttpServletResponse hsr1, List<Inventario> inventario) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/*from w ww . ja va 2s . c o m*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK); Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24); font2.setColor(BaseColor.BLACK); document.add(new Paragraph("TAILS 2015", font1)); document.add(new Paragraph("Reportes Direccin\n", font2)); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Inventarios"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF TextoPdf x = (TextoPdf) model.get("todoTexto"); document.add(new Paragraph(x.getTodoTexto())); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 2.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Total de Inventarios", font)); table.addCell(cell); for (int i = 0; i < inventario.size(); i++) { a = inventario.get(i).getPrecioUnitario(); b = a + b; } String bla = b + " "; table.addCell(bla); document.add(table); //-------------------------- FIN CONTENIDO ----------------- document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void reporteRH(Map<String, Object> model, HttpServletResponse hsr1, int detalle) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();//from w w w . j a v a 2 s . co m document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK); Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24); font2.setColor(BaseColor.BLACK); document.add(new Paragraph("TAILS 2015", font1)); document.add(new Paragraph("Reportes Direccin\n", font2)); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Recursos Humanos"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF TextoPdf x = (TextoPdf) model.get("todoTexto"); document.add(new Paragraph(x.getTodoTexto())); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 2.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Total de de Empleados en Vacaciones", font)); table.addCell(cell); String bla = detalle + " "; table.addCell(bla); document.add(table); //-------------------------- FIN CONTENIDO ----------------- document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void reportefinanzas(Map<String, Object> model, HttpServletResponse hsr1, List<CuentaBancaria> cuenta) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/*from w ww .j a v a2s . c o m*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK); Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24); font2.setColor(BaseColor.BLACK); document.add(new Paragraph("TAILS 2015", font1)); document.add(new Paragraph("Reportes Direccin\n", font2)); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Finanzas"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF TextoPdf x = (TextoPdf) model.get("todoTexto"); document.add(new Paragraph(x.getTodoTexto())); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 2.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Total de dinero que se tiene en CUENTAS BANCARIAS", font)); table.addCell(cell); for (int i = 0; i < cuenta.size(); i++) { a = cuenta.get(i).getHaber(); b = b + a; } String bla = b + " "; table.addCell(bla); document.add(table); //-------------------------- FIN CONTENIDO ----------------- document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java
License:Open Source License
public static void setCellProperties(PdfPCell cell) { cell.setBorder(0);/*from www.j a v a 2s .c o m*/ cell.setPadding(0); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); }
From source file:com.softwaremagico.tm.pdf.complete.elements.LateralHeaderPdfPTable.java
License:Open Source License
protected PdfPCell createLateralVerticalTitle(String title, int rowspan) { Font font = new Font(FadingSunsTheme.getTitleFont(), getTitleFontSize()); font.setColor(BaseColor.WHITE);/* w ww .j a va2 s . co m*/ Phrase content = new Phrase(title, font); PdfPCell titleCell = new PdfPCell(content); titleCell.setPadding(0); titleCell.setRowspan(rowspan); titleCell.setRotation(90); titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); // titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); titleCell.setBackgroundColor(BaseColor.BLACK); return titleCell; }
From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java
License:Open Source License
private static PdfPCell getThirdColumnTable(CharacterPlayer characterPlayer, String language, Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);//from w ww. j a v a 2s . com PdfPCell cell = new PdfPCell(); setCellProperties(cell); for (int i = 0; i < ROWS - OCCULTISM_ROWS; i++) { // Two columns: skill and value. table.addCell(learnedSkillsRows.pop()); table.addCell(learnedSkillsRows.pop()); } // Add Occultism table PdfPTable occultismTable = new OccultismTable(characterPlayer, language); PdfPCell occulstimCell = new PdfPCell(); // setCellProperties(occulstimCell); // occulstimCell.setRowspan(widths.length); occulstimCell.setRowspan(OCCULTISM_ROWS); occulstimCell.setColspan(2); occulstimCell.addElement(occultismTable); occulstimCell.setVerticalAlignment(Element.ALIGN_BOTTOM); occulstimCell.setPadding(0); table.addCell(occulstimCell); cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.skills.MainSkillsTableFactory.java
License:Open Source License
public static PdfPTable getSkillsTable(CharacterPlayer characterPlayer, String language) throws InvalidXmlElementException { float[] widths = { 1f, 12f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);//w w w . j av a2s . c om PdfPCell separator = createSeparator(); separator.setPadding(PADDING); table.addCell(separator); table.addCell(separator); table.addCell(separator); PdfPCell vitalityCell = new PdfPCell(new VitalityTable(characterPlayer)); vitalityCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT); vitalityCell.setPadding(0); table.addCell(vitalityCell); PdfPCell skillsCell = new PdfPCell(CompleteSkillsTable.getSkillsTable(characterPlayer, language)); skillsCell.setBorder(0); skillsCell.setPadding(0); skillsCell.setPaddingRight(FadingSunsTheme.DEFAULT_MARGIN); skillsCell.setPaddingLeft(FadingSunsTheme.DEFAULT_MARGIN); table.addCell(skillsCell); PdfPCell wyrdCell = new PdfPCell(new WyrdTable(characterPlayer)); wyrdCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT); wyrdCell.setPadding(0); table.addCell(wyrdCell); return table; }
From source file:com.softwaremagico.tm.pdf.complete.skills.occultism.OccultismTable.java
License:Open Source License
private PdfPCell createContent(CharacterPlayer characterPlayer, String language) throws InvalidXmlElementException { float[] widths = { 3f, 1f, 1f, 3f }; PdfPTable table = new PdfPTable(widths); BaseElement.setTablePropierties(table); table.getDefaultCell().setBorder(0); table.getDefaultCell().setPadding(0); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); for (OccultismType occulstimType : OccultismTypeFactory.getInstance().getElements(language)) { PdfPCell psiqueTitleCell = new PdfPCell(new Phrase(occulstimType.getName(), new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE))); psiqueTitleCell.setBorder(0);// w w w .j a v a2 s.c om // psiTitleCell.setMinimumHeight(30); psiqueTitleCell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(psiqueTitleCell); if (characterPlayer == null) { table.addCell(createRectangle()); table.addCell(createRectangle()); } else { table.addCell(createRectangle(characterPlayer.getPsiqueLevel(occulstimType))); table.addCell(createRectangle(characterPlayer.getDarkSideLevel(occulstimType))); } PdfPCell darkSideTitleCell = new PdfPCell(new Phrase(occulstimType.getDarkSideName(), new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE))); darkSideTitleCell.setBorder(0); darkSideTitleCell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(darkSideTitleCell); } PdfPCell cell = new PdfPCell(); cell.addElement(table); cell.setPadding(0); BaseElement.setCellProperties(cell); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.traits.MainPerksTableFactory.java
License:Open Source License
public static PdfPTable getPerksTable(CharacterPlayer characterPlayer) { float[] widths = { 4f, 0.1f, 4f, 0.1f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);//w w w . j a va 2s . com table.getDefaultCell().setPadding(PADDING); PdfPCell whiteSeparator = createWhiteSeparator(); whiteSeparator.setColspan(widths.length); table.addCell(whiteSeparator); PdfPCell blackSeparator = createBlackSeparator(); whiteSeparator.setColspan(1); table.addCell(blackSeparator); table.addCell(whiteSeparator); table.addCell(blackSeparator); table.addCell(whiteSeparator); PdfPCell victoryPointsCell = new PdfPCell(new VictoryPointsTable()); victoryPointsCell.setPadding(0); victoryPointsCell.setRowspan(2); table.addCell(victoryPointsCell); PdfPCell blessingCell = new PdfPCell(new BlessingTable(characterPlayer)); blessingCell.setPadding(0); blessingCell.setBorder(0); table.addCell(blessingCell); table.addCell(whiteSeparator); PdfPCell perksCell = new PdfPCell(new BeneficesTable(characterPlayer)); perksCell.setPadding(0); perksCell.setBorder(0); table.addCell(perksCell); table.addCell(whiteSeparator); return table; }
From source file:com.softwaremagico.tm.pdf.small.SmallCharacterSheet.java
License:Open Source License
protected PdfPTable createCharacterContent(CharacterPlayer characterPlayer) throws Exception { float[] widths = { 2.2f, 1f }; PdfPTable mainTable = new PdfPTable(widths); BaseElement.setTablePropierties(mainTable); mainTable.getDefaultCell().setPadding(0); PdfPTable infoTable = CharacterBasicsReducedTableFactory.getCharacterBasicsTable(characterPlayer); PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorderWidthTop(0);//from w ww. java2 s . c om infoCell.setBorderWidthLeft(0); infoCell.setBorderWidthBottom(1); mainTable.addCell(infoCell); PdfPTable learnedSkillsTable = LearnedSkillsTable.getSkillsTable(characterPlayer, getLanguage()); PdfPCell learnedSkillsCell = new PdfPCell(learnedSkillsTable); learnedSkillsCell.setColspan(2); learnedSkillsCell.setRowspan(3); learnedSkillsCell.setBorderWidthTop(0); learnedSkillsCell.setBorderWidthRight(0); mainTable.addCell(learnedSkillsCell); PdfPTable basicTable = new PdfPTable(new float[] { 5f, 4f }); BaseElement.setTablePropierties(basicTable); basicTable.getDefaultCell().setBorder(0); PdfPTable characteristicsTable = CharacteristicsTableFactory.getCharacteristicsBasicsTable(characterPlayer); PdfPCell characteristicCell = new PdfPCell(characteristicsTable); characteristicCell.setBorderWidthLeft(0); basicTable.addCell(characteristicCell); PdfPTable naturalSkillsTable = NaturalSkillsTable.getSkillsTable(characterPlayer, getLanguage()); PdfPCell naturalSkillsCell = new PdfPCell(naturalSkillsTable); naturalSkillsCell.setBorderWidthRight(0); basicTable.addCell(naturalSkillsCell); PdfPCell basicComposedCell = new PdfPCell(basicTable); basicComposedCell.setBorder(0); mainTable.addCell(basicComposedCell); PdfPTable composedTable = new PdfPTable(new float[] { 5f, 2f }); PdfPTable blessingsTable = new BlessingTable(characterPlayer); PdfPCell blessingsCell = new PdfPCell(blessingsTable); blessingsCell.setBorderWidthLeft(0); blessingsCell.setBorderWidthBottom(1); composedTable.addCell(blessingsCell); PdfPTable beneficesTable = new BeneficesTable(characterPlayer); PdfPCell beneficesCell = new PdfPCell(beneficesTable); beneficesCell.setBorderWidthBottom(1); composedTable.addCell(beneficesCell); PdfPCell composedCell = new PdfPCell(composedTable); composedCell.setRowspan(2); composedCell.setBorder(0); mainTable.addCell(composedCell); PdfPTable armourTable = new ArmourTable(characterPlayer); PdfPCell armourCell = new PdfPCell(armourTable); armourCell.setBorderWidthRight(0); armourCell.setBorderWidthBottom(1); mainTable.addCell(armourCell); PdfPTable fightTable = new PdfPTable(new float[] { 3f, 5f, 1f }); if (characterPlayer != null && (characterPlayer.getSelectedPowers().isEmpty() && !characterPlayer.getCybernetics().isEmpty())) { PdfPTable cyberneticsTable = new CyberneticsTable(characterPlayer); PdfPCell cyberneticsCell = new PdfPCell(cyberneticsTable); cyberneticsCell.setBorderWidthLeft(0); fightTable.addCell(cyberneticsCell); } else { PdfPTable occultismTable = new OccultismTable(characterPlayer, getLanguage()); PdfPCell occultismCell = new PdfPCell(occultismTable); occultismCell.setBorderWidthLeft(0); fightTable.addCell(occultismCell); } PdfPTable weaponsTable = new WeaponsTable(characterPlayer); fightTable.addCell(weaponsTable); PdfPCell victoryPointsCell = new PdfPCell(new VerticalVictoryPointsTable()); victoryPointsCell.setPadding(0); victoryPointsCell.setRowspan(3); fightTable.addCell(victoryPointsCell); PdfPTable vitalityTable = new VitalityTable(characterPlayer); PdfPCell vitalityCell = new PdfPCell(vitalityTable); vitalityCell.setColspan(2); vitalityCell.setBorderWidth(1); fightTable.addCell(vitalityCell); PdfPTable wyrdTable = new WyrdTable(characterPlayer); PdfPCell wyrdCell = new PdfPCell(wyrdTable); wyrdCell.setBorderWidth(1); wyrdCell.setColspan(2); fightTable.addCell(wyrdCell); PdfPCell fightCell = new PdfPCell(fightTable); fightCell.setBorder(0); fightCell.setColspan(2); mainTable.addCell(fightCell); return mainTable; }