List of usage examples for com.itextpdf.text FontFactory TIMES_ROMAN
String TIMES_ROMAN
To view the source code for com.itextpdf.text FontFactory TIMES_ROMAN.
Click Source Link
From source file:bestdeal.util.genererPdf.java
public static void main(String[] args) { // - Paramtres de connexion la base de donnes Connection connection;/*from w ww .j a v a 2s . com*/ String[][] data = new String[][] { { " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " " }, }; try { String requete = "select c.nom,c.prenom,c.email,k.nom,k.prenom,k.telephone,k.adresse,k.email,d.id_deal,d.nom_deal,v.quantite,v.prix_unitaire from client c INNER JOIN voucher v on v.id_client=c.id_client INNER JOIN deal d on v.id_deal=d.id_deal INNER JOIN vendeur k on d.id_vendeur=k.id_vendeur"; connection = MyConnection.getInstance(); mypdf = new Document(PageSize.A4, 50, 50, 50, 50); File di = new File("C:/Voucher"); File fl[] = di.listFiles(); try { OutputStream file = new FileOutputStream(new File("C:/Voucher\\Voucher.pdf")); PdfWriter.getInstance(mypdf, file); mypdf.open(); Statement stm; mypdf.addAuthor("Best Deal"); mypdf.addSubject("Voucher "); mypdf.add(new Paragraph("Socite BestDeal")); mypdf.add(new Paragraph("Adresse La Chotrana ESPRIT ")); mypdf.add(new Paragraph("TEL : xx xxx xxx")); mypdf.add(new Paragraph("FAX : xx xxx xxx")); mypdf.add(new Paragraph( " " + new Date().toString())); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" " + "Voucher N'01", FontFactory.getFont(FontFactory.HELVETICA, 21, Font.BOLDITALIC))); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph("CLIENT :", FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC))); try { stm = connection.createStatement(); ResultSet rs = stm.executeQuery(requete); while (rs.next()) { // add a country to the document as a Chunk //mypdf.add(new Chunk(rs.getString("quantite"))); Phrase p = new Phrase("Nom: "); Phrase p2 = new Phrase(new Chunk(rs.getString("nom"))); Paragraph pa = new Paragraph(); pa.add(p); pa.add(p2); mypdf.add(pa); Phrase p3 = new Phrase("Prenom: "); Phrase p4 = new Phrase(new Chunk(rs.getString("prenom"))); Paragraph pa1 = new Paragraph(); pa1.add(p3); pa1.add(p4); mypdf.add(pa1); Phrase p5 = new Phrase("Adresse: "); Phrase p6 = new Phrase(new Chunk(rs.getString("adresse"))); Paragraph pa2 = new Paragraph(); pa2.add(p5); pa2.add(p6); mypdf.add(pa2); Phrase p7 = new Phrase("Tlphone: "); Phrase p8 = new Phrase(new Chunk(rs.getString("telephone"))); Paragraph pa3 = new Paragraph(); pa3.add(p7); pa3.add(p8); mypdf.add(pa3); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph("Vendeur :", FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC))); Phrase p9 = new Phrase("Nom: "); Phrase p10 = new Phrase(new Chunk(rs.getString("nom"))); Paragraph pa4 = new Paragraph(); pa4.add(p9); pa4.add(p10); mypdf.add(pa4); Phrase p11 = new Phrase("Prnom: "); Phrase p12 = new Phrase(new Chunk(rs.getString("prenom"))); Paragraph pa5 = new Paragraph(); pa5.add(p11); pa5.add(p12); mypdf.add(pa5); Phrase p13 = new Phrase("Tlphone: "); Phrase p14 = new Phrase(new Chunk(rs.getString("telephone"))); Paragraph pa6 = new Paragraph(); pa6.add(p13); pa6.add(p14); mypdf.add(pa6); Phrase p15 = new Phrase("Adresse: "); Phrase p16 = new Phrase(new Chunk(rs.getString("adresse"))); Paragraph pa7 = new Paragraph(); pa7.add(p15); pa7.add(p16); mypdf.add(pa7); Phrase p17 = new Phrase("Email: "); Phrase p18 = new Phrase(new Chunk(rs.getString("email"))); Paragraph pa8 = new Paragraph(); pa8.add(p17); pa8.add(p18); mypdf.add(pa8); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); for (int i = 0; i < rs.getRow(); i++) { for (int j = 0; j < data[i].length - 1; j++) { data[i][j] = rs.getString(j + 9); // if (j==3) // data[i][4]= Float.parseFloat(data[i][3])*Integer.parseInt(data[i][2])+""; } } for (int i = 0; i < rs.getRow(); i++) { float s = Integer.parseInt(data[i][2].trim()) * Float.parseFloat(data[i][3].trim()); data[i][4] = s + ""; } //mypdf.add(new Phrase("nom")); //mypdf.add(new Chunk(rs.getString("nom"))); //mypdf.add( new Paragraph("nom:", new Chunk(rs.getString("nom")))); //mypdf.add(new Chunk(" ")); //Chunk id = new Chunk(rs.getString("id")); // with a background color //id.setBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f); // and a text rise //id.setTextRise(6); // mypdf.add(id); mypdf.add(Chunk.NEWLINE); } } catch (SQLException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } // mypdf.add(new Paragraph("Nom ")); // mypdf.add(new Paragraph("Prenom ")); // mypdf.add(new Paragraph("Adresse ")); //mypdf.add(new Paragraph("Tlphone ")); // mypdf.add(new Paragraph("Nom ")); // mypdf.add(new Paragraph("Nom de la socit ")); // mypdf.add(new Paragraph("Adresse ")); // mypdf.add(new Paragraph("Tlphone ")); // mypdf.add(new Paragraph(" ")); String[] headers = new String[] { " Id_deal", " Nom Deal", " Quantit", " Prix unitaire", " Prix total" }; PdfPTable table = new PdfPTable(headers.length); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setGrayFill(0.9f); cell.setPhrase(new Phrase(header.toUpperCase())); table.addCell(cell); } table.completeRow(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { String datum = data[i][j]; PdfPCell cell = new PdfPCell(); cell.setPhrase(new Phrase(datum.toUpperCase())); table.addCell(cell); } table.completeRow(); } mypdf.add(table); } catch (FileNotFoundException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph( "Pour toute question concernant cette facture,veuillez contacter Nom,numro de tlphone,adresse de messagerie ", FontFactory.getFont(null, 9, Font.NORMAL))); mypdf.add(new Paragraph( " Merci pour votre confiance", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLDITALIC))); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.close(); } catch (DocumentException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.ftt.gui.FrameFormation.java
private void pdf1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdf1ActionPerformed if (nomf.getText() == null || descriptionf.getText() == null || "".equals(lieux.getText()) || dateclot.getDate() == null || dateov.getDate() == null) { JOptionPane.showMessageDialog(this, "Vrifier les champs !"); } else {//from w w w.j a v a2 s. c om SimpleDateFormat formateur = new SimpleDateFormat("dd-MM-yyyy"); String val1 = lieux.getText(); String val2 = formateur.format(dateov.getDate()); String val3 = formateur.format(dateclot.getDate()); String val4 = combocible.getSelectedItem().toString(); String val5 = nomf.getText(); String val6 = descriptionf.getText(); Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream("rapport.pdf")); document.open(); com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance("ftt.png"); document.add(image); document.add(new Paragraph("Liste des formations", FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.BOLD))); document.add(new Paragraph(formateur.format(new Date()))); String val322 = formateur.format(new Date()); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(2); PdfPCell cell = new PdfPCell(new Paragraph("formations")); cell.setColspan(4); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.BLUE); table.addCell(cell); table.addCell("Nom formation"); table.addCell(val5); table.addCell(cell); table.addCell("Description"); table.addCell(val6); table.addCell(cell); table.addCell("Lieux"); table.addCell(val1); table.addCell("Date d'ouverture"); table.addCell(val2); table.addCell("Date de cloture"); table.addCell(val3); table.addCell("Cible"); table.addCell(val4); document.add(table); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Responsable des formations")); document.add(new Paragraph("Federation Tunisenne de Tennis")); document.close(); JOptionPane.showMessageDialog(null, "Rapport Enregistrer"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } }
From source file:com.ftt.gui.FrameFormation.java
private void pdf2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdf2ActionPerformed FormationDAO fd = new FormationDAO(); ArrayList<Formation> formations = (ArrayList<Formation>) fd.select(); SimpleDateFormat formateur = new SimpleDateFormat("dd-MM-yyyy"); Document document = new Document(); try {/* w w w . j a v a 2s . co m*/ PdfWriter.getInstance(document, new FileOutputStream("rapport_formations.pdf")); document.open(); com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance("ftt.png"); document.add(image); document.add(new Paragraph("Liste des formations", FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.BOLD))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); for (int i = 0; i < formations.size(); i++) { document.add(new Paragraph(" ")); int val = formations.get(i).getId(); String val1 = formations.get(i).getLieux(); String val2 = formations.get(i).getDateOuverture(); String val3 = formations.get(i).getDateCloture(); String val4 = formations.get(i).getCible(); String val5 = formations.get(i).getNom(); String val6 = formations.get(i).getDescription(); PdfPTable table = new PdfPTable(2); PdfPCell cell = new PdfPCell(new Paragraph("formation " + val)); cell.setColspan(4); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); table.addCell("Nom formation"); table.addCell(val5); table.addCell("Description"); table.addCell(val6); table.addCell("Lieux"); table.addCell(val1); table.addCell("Date d'ouverture"); table.addCell(val2); table.addCell("Date de cloture"); table.addCell(val3); table.addCell("Cible"); table.addCell(val4); document.add(table); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Responsable des formations")); document.add(new Paragraph("Federation Tunisenne de Tennis")); document.close(); JOptionPane.showMessageDialog(null, "Rapport Enregistrer"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } }
From source file:com.ftt.gui.FrameJoueur.java
private void pdf2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdf2ActionPerformed JoueurDAO fd = new JoueurDAO(); ArrayList<Joueur> joueurs = (ArrayList<Joueur>) fd.select_trie_par_club(); SimpleDateFormat formateur = new SimpleDateFormat("dd-MM-yyyy"); Document document = new Document(); try {// ww w . j av a 2s.com PdfWriter.getInstance(document, new FileOutputStream("rapport_joueurs.pdf")); document.open(); com.itextpdf.text.Image image = com.itextpdf.text.Image.getInstance("ftt.png"); document.add(image); document.add(new Paragraph("Liste des joueurs", FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.BOLD))); document.add(new Paragraph(" ")); for (int i = 0; i < joueurs.size(); i++) { document.add(new Paragraph(" ")); document.add(new Paragraph(joueurs.get(i).getNom_club())); document.add(new Paragraph(" ")); Integer val = joueurs.get(i).getId(); String val1 = joueurs.get(i).getNomJoueur(); String val2 = joueurs.get(i).getPrenomJoueur(); String val3 = joueurs.get(i).getDateNaissance(); String val4 = joueurs.get(i).getCarriere(); String val5 = joueurs.get(i).getSexe(); Integer val6 = joueurs.get(i).getPoints(); PdfPTable table = new PdfPTable(2); PdfPCell cell = new PdfPCell(new Paragraph("Joueur id: " + val)); cell.setColspan(4); cell.setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_LEFT); cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); table.addCell("Nom"); table.addCell(val1); table.addCell("Prenom"); table.addCell(val2); table.addCell("Date de naissance"); table.addCell(val3); table.addCell("Carriere"); table.addCell(val4); table.addCell("sexe"); table.addCell(val5); table.addCell("points"); table.addCell(val6.toString()); document.add(table); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Federation Tunisenne de Tennis")); document.close(); JOptionPane.showMessageDialog(null, "Rapport Enregistrer"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } }
From source file:com.mx.ipn.clases.PDF.java
public void crearpdf(String nombre, String appat, String apmat) throws FileNotFoundException, DocumentException { // Creacion del documento con los margenes // Creacion del documento con los margenes Document document = new Document(PageSize.A4, 35, 30, 50, 50); try {// w w w . jav a 2 s. c o m // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream("AvisoPrivacidad.pdf"); // Obtener la instancia del PdfWriter PdfWriter.getInstance(document, fileOutputStream); // Abrir el documento document.open(); // Crear las fuentes para el contenido y los titulos Font fontContenido = FontFactory.getFont(FontFactory.TIMES_ROMAN.toString(), 9, Font.NORMAL, BaseColor.DARK_GRAY); Font fontTitulos = FontFactory.getFont(FontFactory.TIMES_BOLD, 11, Font.UNDERLINE, BaseColor.DARK_GRAY); Font nomb = FontFactory.getFont(FontFactory.TIMES_BOLD, 9, Font.NORMAL, BaseColor.DARK_GRAY); // Creacion del parrafo Paragraph paragraph = new Paragraph(); // Agregar un titulo con su respectiva fuente paragraph.add(new Phrase("Aviso de Privacidad", fontTitulos)); paragraph.setAlignment(Element.ALIGN_CENTER); // Agregar saltos de linea paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); // Agregar contenido con su respectiva fuente paragraph.add(new Phrase( "Con fundamento en los artculos 15, 16 y de acuerdo a lo Previsto en la Ley Federal de Proteccin de Datos" + "Personales, hacemos de su conocimiento que ZERCHERS, S.A. de C.V., es una empresa legalmente" + "constituido de conformidad con las leyes mexicanas, con domicilio en Av. Juan de Dios Btiz s/n, Gustavo" + "A. Madero, Nueva Industrial Vallejo, 07700 Ciudad de Mxico; y como responsable del tratamiento de sus" + "datos personales, del uso que se le d a los mismos y de su proteccin. Hace de su conocimiento que la" + "informacin de nuestros clientes es tratada de forma estrictamente confidencial por lo que, al proporcionar" + "sus datos personales. Estos sern utilizados nica y exclusivamente para los siguientes fines: " + "Proveer los servicios y productos que ha solicitado; notificarle sobre nuevos servicios o productos que" + "tengan relacin con los ya contratados o adquiridos; comunicarle sobre cambios en los mismos; evaluar la" + "calidad de los servicios que brindamos; mantener actualizada nuestra base de datos con sus datos" + "recientes y en general, para dar cumplimiento a las obligaciones que hemos contrado con usted.", fontContenido)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase( " Para las finalidades antes mencionadas, requerimos obtener los siguientes datos personales:", fontContenido)); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); // Agregar el parrafo al documento document.add(paragraph); document.add(Tabla_Simple()); paragraph = new Paragraph(); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase( "Para prevenir el acceso no autorizado a sus datos personales y con el fin de asegurar que la informacin sea " + "utilizada para los fines establecidos en este aviso de privacidad, hemos establecido diversos procedimientos" + " con la finalidad de evitar el uso o divulgacin no autorizados de sus datos, permitindonos tratarlos debidamente." + " As mismo, le informamos que sus datos personales pueden ser Transmitidos para ser tratados por personas " + "distintas a esta empresa. Todos sus datos personales son tratados de acuerdo a la legislacin aplicable y " + "vigente en el pas, por ello le informamos que usted tiene en todo momento los derechos (ARCO) de acceder, " + "rectificar, cancelar u oponerse al tratamiento que le damos a sus datos personales; derecho que podr " + "hacer valer a travs del ?rea de Privacidad encargada de la seguridad de datos personales en el " + "Telfono 5729 6000.", fontContenido)); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase( " A travs de estos canales usted podr actualizar sus datos y especificar el medio por el cual desea recibir " + "informacin, ya que en caso de no contar con esta especificacin de su parte, ZERCHERS, S.A. de C.V., " + "establecer libremente el canal que considere pertinente para enviarle informacin. Este aviso de" + " privacidad podr ser modificado por ZERCHERS, S.A. de C.V., dichas modificaciones sern oportunamente " + "informadas a travs de correo electrnico, telfono, pgina web o cualquier otro medio de comunicacin" + " que ZERCHERS, S.A. de C.V., determine para tal efecto.", fontContenido)); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(" ATENTAMENTE", nomb)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(" Direccin General TT/SisPLD", nomb)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(" Consiento que mis datos personales sensibles sean tratados conforme a" + "los trminos y condiciones del presente aviso de privacidad.", fontContenido)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase("Nombre: " + nombre + " " + appat + " " + apmat, nomb)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase("____________________________________", fontContenido)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(Chunk.NEWLINE)); paragraph.add(new Phrase(" ltima Fecha de Emisin: Mayo 13, 2016", fontContenido)); document.add(paragraph); // Cerrar el documento document.close(); // Abrir el archivo File file = new File("AvisoPrivacidad.pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.sapito.direccion.PdfBuildertextV.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter pdfWriter, HttpServletRequest request, HttpServletResponse response) throws Exception { Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK);// ww w .j a va 2s. c o m 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)); TextoPdf x = (TextoPdf) model.get("todoTexto"); // System.out.println(x.getTodoTexto()); document.add(new Paragraph(x.getTodoTexto())); // // List<Book> listBooks = (List<Book>) model.get("listBooks"); // // document.add(new Paragraph("\nReporte de Ventas\n")); // PdfPTable table = new PdfPTable(2); // table.setWidthPercentage(100.0f); // table.setWidths(new float[]{3.0f, 2.0f}); // table.setSpacingBefore(10); // // // define font for table header row // Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); // font.setColor(BaseColor.WHITE); // // // PdfPCell cell = new PdfPCell(); // cell.setBackgroundColor(BaseColor.BLUE); // cell.setPadding(5); // // // cell.setPhrase(new Phrase("Categoria", font)); // table.addCell(cell); // // cell.setPhrase(new Phrase("Monto", font)); // table.addCell(cell); // // // document.add(table); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void crearPDFFactura(Map<String, Object> model, HttpServletResponse hsr1, List<Producto> tipo) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/* www . j a v 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 Ventas"; //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 table3 = new PdfPTable(3); table3.setWidthPercentage(100.0f); table3.setWidths(new float[] { 2.0f, 2.0f, 2.0f }); table3.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("Nombre", font)); table3.addCell(cell); cell.setPhrase(new Phrase("Categoria", font)); table3.addCell(cell); cell.setPhrase(new Phrase("Marca", font)); table3.addCell(cell); Depreciacion dep = new Depreciacion(); for (int i = 0; i < tipo.size(); i++) { //a = dep.getResultado(); //b = dep.getValorADep(); table3.addCell(tipo.get(i).getNombreProducto()); table3.addCell(tipo.get(i).getCategoria()); table3.addCell(tipo.get(i).getMarca()); } // String bla = a + " "; // String bl = b + " "; // table3.addCell(bla); // table3.addCell(bl); document.add(table3); //-------------------------- 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 reporteventa(Map<String, Object> model, HttpServletResponse hsr1, List<OrdenVenta> ordenventa) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();//from w w w . j a v a2 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 Ventas"; //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 ventas en el dia", font)); table.addCell(cell); for (int i = 0; i < ordenventa.size(); i++) { a = ordenventa.get(i).getMontoConCargos(); 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 reportecompras(Map<String, Object> model, HttpServletResponse hsr1, List<OrdenCompra> ordenCompra) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/* ww w . j a va2 s. 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 Compras"; //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 Compras en el dia", font)); table.addCell(cell); for (int i = 0; i < ordenCompra.size(); i++) { a = ordenCompra.get(i).getCostoTotal(); 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 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();/* w w w . jav a 2 s .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 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); }