List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
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 ww .j av a 2s . c om*/ 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 av a 2s. 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 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.skatettoo.reportes.Generador.java
public String generarPDF() throws Exception { try {/*from www . jav a 2 s .com*/ String path = FacesContext.getCurrentInstance().getExternalContext().getRealPath("img"); path = path.substring(0, path.indexOf("\\build")); path = path + "\\web\\img\\"; Document doc = new Document(PageSize.A4, 36, 36, 10, 10); PdfPTable tabla = new PdfPTable(4); PdfWriter.getInstance(doc, new FileOutputStream(path + "\\archivo\\reporte.pdf\\")); doc.open(); Image img = Image.getInstance(path + "Skatetoo4.png"); img.scaleAbsolute(40, 40); img.setAlignment(Element.ALIGN_LEFT); doc.add(img); doc.addTitle(this.titulo); doc.addAuthor("\n "); doc.addAuthor("\n "); doc.addAuthor("\n "); doc.addAuthor("\n "); tabla.setWidthPercentage(100); tabla.setWidths(new float[] { 1.4f, 0.8f, 0.8f, 0.8f }); Object font = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD, BaseColor.WHITE); PdfPCell cell = new PdfPCell(new Phrase("Reporte de tatuadores", (Font) font)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(0f); cell.setPaddingBottom(7f); cell.setBackgroundColor(new BaseColor(0, 0, 0)); cell.setBorder(0); cell.setBorderWidthBottom(2f); tabla.addCell(cell); tabla.addCell("Tatuador"); tabla.addCell("Cantidad de diseos"); tabla.addCell("Citas realizadas"); tabla.addCell("Noticias publicadas"); for (Usuario u : this.getUsu()) { tabla.addCell(u.getNombre() + " " + u.getApellido()); tabla.addCell(String.valueOf(u.getDisenioList().size())); tabla.addCell(String.valueOf(u.getCitaList1().size())); tabla.addCell(String.valueOf(u.getNoticiaList().size())); } doc.add(tabla); doc.bottomMargin(); /* doc.add(new Paragraph("Tatuador mas solicitado")); for(Usuario u : this.getUs()){ doc.add(new Paragraph(u.getNombre() + " " + u.getApellido())); }*/ doc.close(); FacesContext context = FacesContext.getCurrentInstance(); ExternalContext externalContext = context.getExternalContext(); externalContext.responseReset(); externalContext.setResponseContentType("application/pdf"); externalContext.setResponseHeader("Content-Disposition", "attachment;filename=\"reporte.pdf\""); FileInputStream inputStream = new FileInputStream(new File(path + "\\archivo\\reporte.pdf\\")); OutputStream outputStream = externalContext.getResponseOutputStream(); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } inputStream.close(); context.responseComplete(); } catch (Exception e) { throw e; } return ""; }
From source file:com.softwaremagico.tm.pdf.complete.CharacterSheet.java
License:Open Source License
private PdfPTable createRearTable() throws InvalidXmlElementException { PdfPTable mainTable = new PdfPTable(REAR_TABLE_WIDTHS); mainTable.getDefaultCell().setBorder(0); mainTable.setWidthPercentage(100); mainTable.addCell(new DescriptionTable(characterPlayer)); PdfPCell cell = new PdfPCell(new AnnotationsTable()); cell.setBorderWidth(0);//from ww w .j a v a2 s . c o m cell.setColspan(2); mainTable.addCell(cell); PdfPCell blackSeparator = BaseElement.createBigSeparator(90); mainTable.addCell(blackSeparator); PdfPCell separatorCell = new PdfPCell(BaseElement.createWhiteSeparator()); separatorCell.setColspan(2); mainTable.addCell(separatorCell); mainTable.addCell(new PropertiesTable(characterPlayer)); PdfPCell psiCell = new PdfPCell(new OccultismsPowerTable(characterPlayer, PSI_ROWS)); psiCell.setColspan(2); mainTable.addCell(psiCell); mainTable.addCell(BaseElement.createBigSeparator(90)); mainTable.addCell(separatorCell); PdfPTable othersTable = new OthersTable(); mainTable.addCell(othersTable); PdfPCell cyberneticsCell = new PdfPCell(new CyberneticsTable(characterPlayer)); cyberneticsCell.setColspan(2); mainTable.addCell(cyberneticsCell); return mainTable; }
From source file:com.softwaremagico.tm.pdf.complete.CharacterSheet.java
License:Open Source License
private PdfPTable createRearTablePsiExtended() throws InvalidXmlElementException { PdfPTable mainTable = new PdfPTable(REAR_TABLE_WIDTHS); mainTable.getDefaultCell().setBorder(0); mainTable.setWidthPercentage(100); mainTable.addCell(new DescriptionTable(characterPlayer)); PdfPCell cell = new PdfPCell(new AnnotationsTable()); cell.setBorderWidth(0);// w w w .ja v a2 s . co m cell.setColspan(2); mainTable.addCell(cell); PdfPCell blackSeparator = BaseElement.createBigSeparator(90); mainTable.addCell(blackSeparator); PdfPCell separatorCell = new PdfPCell(BaseElement.createWhiteSeparator()); separatorCell.setColspan(2); mainTable.addCell(separatorCell); mainTable.addCell(new PropertiesTable(characterPlayer)); PdfPCell psiCell = new PdfPCell(new OccultismsPowerTable(characterPlayer, PSI_EXTENDED_ROWS)); psiCell.setColspan(2); psiCell.setRowspan(3); mainTable.addCell(psiCell); mainTable.addCell(BaseElement.createBigSeparator(90)); PdfPTable othersTable = new OthersTable(); mainTable.addCell(othersTable); return mainTable; }
From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java
License:Open Source License
public static PdfPCell createSeparator() { float[] widths = { 1f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100); table.addCell(createWhiteSeparator()); table.addCell(createBlackSeparator()); // table.addCell(createWhiteSeparator()); PdfPCell cell = new PdfPCell(); cell.addElement(table);/*from ww w . ja va 2 s . com*/ setCellProperties(cell); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java
License:Open Source License
public static PdfPCell createBigSeparator(int width) { float[] widths = { 1f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(width); table.addCell(createWhiteSeparator()); table.addCell(createBlackSeparator()); table.addCell(createWhiteSeparator()); PdfPCell cell = new PdfPCell(); cell.addElement(table);//from w w w .jav a2 s . c o m setCellProperties(cell); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java
License:Open Source License
public static void setTablePropierties(PdfPTable table) { table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.setWidthPercentage(100); table.setPaddingTop(0);//from ww w. j ava2s .co m table.setSpacingAfter(0); table.setSpacingBefore(0); }
From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private void createTable(Document doc, EnableRequerimentTypeFederalEnum type, EnableRequerimentSubjectFederalEnum subject, LicensePFEntity license, UserEntity user) throws DocumentException { // create PDF table with the given widths PdfPTable table = new PdfPTable(4); // set table width a percentage of the page width table.setWidthPercentage(100f); // Alterao Cadastral this.createAlteracaoCadastral(table, type, subject); // Dados da Empresa this.createCompany(table, license); // Dados do Representante this.createRepresentant(table, user); // Deferimento this.createDeferiment(table, license.getCompany()); // Uso Oficial this.insertCellProtocol(table, license); // Table pai PdfPTable tableFather = new PdfPTable(1); tableFather.setWidthPercentage(100f); PdfPCell cellFather = new PdfPCell(table); cellFather.setBorderWidth(2);/*w ww . ja v a2 s.co m*/ tableFather.addCell(cellFather); doc.add(this.createHeader()); doc.add(tableFather); }
From source file:com.solidmaps.webapp.report.LicenseCivilIncludeProductPDF.java
License:Open Source License
private void generateProducts(Document doc, List<LicensePCProductEntity> listProducts) throws DocumentException { DecimalFormat dc = new DecimalFormat("########0.00"); // specify column widths float[] columnWidths = { 2f, 2f, 2f }; // create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(100f); // insert column headings insertCell(table, "Nome da Substncia de Controle", Element.ALIGN_CENTER, FONT_PARAGRAPH); insertCell(table, "Volume mximo de estoque", Element.ALIGN_CENTER, FONT_PARAGRAPH); insertCell(table, "Unidade de medida", Element.ALIGN_CENTER, FONT_PARAGRAPH); table.setHeaderRows(1);// ww w. j ava2s . c om for (LicensePCProductEntity product : listProducts) { // Cria a tabela com os Produtos insertCell(table, product.getProduct().getName(), Element.ALIGN_LEFT, FONT_PARAGRAPH); insertCell(table, dc.format(product.getQtdProduct()), Element.ALIGN_LEFT, FONT_PARAGRAPH); insertCell(table, product.getTypeQtdProduct(), Element.ALIGN_LEFT, FONT_PARAGRAPH); } doc.add(Chunk.NEXTPAGE); doc.add(table); }