List of usage examples for com.itextpdf.text Font BOLDITALIC
int BOLDITALIC
To view the source code for com.itextpdf.text Font BOLDITALIC.
Click Source Link
From source file:imprimer.java
public void conje() { Document document = new Document(PageSize.A4); try {//from w w w. java 2s . c om PdfWriter.getInstance(document, new FileOutputStream("conjee.pdf")); document.open(); imagee(document); SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy"); java.util.Date now = new java.util.Date(); String tdnow = td.format(now); Paragraph pa = new Paragraph("Dcision de cong", FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY)); pa.setAlignment(Paragraph.ALIGN_CENTER); document.add(pa); for (int i = 0; i < 4; i++) { document.add(new Paragraph(" ")); } Paragraph p = new Paragraph(text2, FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p); Paragraph p3 = new Paragraph("DECIDE :", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); p3.setAlignment(Paragraph.ALIGN_CENTER); document.add(p3); Paragraph p4 = new Paragraph("ARTICLE I Un cong dun .", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p4); Paragraph p5 = new Paragraph( " Est accord : \n" + " C.I.N : \n" + " GRADE : \n" + " Pour la priode : ", FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p5); Paragraph p6 = new Paragraph("ARTICLE II", FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p6); Paragraph p7 = new Paragraph( "Lintress(e) est autoris quitter le territoire national durant la priode indique ci-dessus", FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p7); Paragraph p8 = new Paragraph("ARTICLE III", FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p8); Paragraph p9 = new Paragraph( "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du cong sus-vis.", FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p9); for (int i = 0; i < 4; i++) { document.add(new Paragraph(" ")); } Paragraph time = new Paragraph( " Cachet et signature Fait Ouarzazate le :" + tdnow + "\n" + "\n", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); Paragraph si = new Paragraph("Signature du demandeur", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); time.setAlignment(Paragraph.ALIGN_LEFT); si.setAlignment(Paragraph.ALIGN_RIGHT); document.add(time); document.add(si); document.close(); System.out.println("date2"); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("conjee.pdf")); } else { System.out.println("Open is not supported"); } System.out.println("date"); } catch (Exception ex) { System.out.println("qsdqs"); } }
From source file:imprimer.java
public void conje_exp() { Document document = new Document(PageSize.A4); try {/*www . j a v a2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream("conjee_exp.pdf")); document.open(); imagee(document); SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy"); java.util.Date now = new java.util.Date(); String tdnow = td.format(now); Paragraph pa = new Paragraph("Dcision de cong", FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY)); pa.setAlignment(Paragraph.ALIGN_CENTER); document.add(pa); for (int i = 0; i < 4; i++) { document.add(new Paragraph(" ")); } Paragraph p = new Paragraph(text2, FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p); Paragraph p3 = new Paragraph("DECIDE :", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); p3.setAlignment(Paragraph.ALIGN_CENTER); document.add(p3); Paragraph p4 = new Paragraph("ARTICLE I", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p4); Paragraph p5 = new Paragraph( " Un cong Exceptionnel dune dure de jours\n" + " Est accord : \n" + " C.I.N : \n" + " GRADE : \n" + " Pour la priode : ", FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p5); Paragraph p6 = new Paragraph("ARTICLE II", FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p6); Paragraph p7 = new Paragraph( "Lintress(e) est autoris quitter le territoire national durant la priode indique ci-dessus", FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p7); Paragraph p8 = new Paragraph("ARTICLE III", FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY)); document.add(p8); Paragraph p9 = new Paragraph( "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du cong sus-vis.", FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY)); document.add(p9); for (int i = 0; i < 4; i++) { document.add(new Paragraph(" ")); } Paragraph time = new Paragraph( " Cachet et signature Fait Ouarzazate le :" + tdnow + "\n" + "\n", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); Paragraph si = new Paragraph("Signature du demandeur", FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY)); time.setAlignment(Paragraph.ALIGN_LEFT); si.setAlignment(Paragraph.ALIGN_RIGHT); document.add(time); document.add(si); document.close(); System.out.println("date2"); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("conjee_exp.pdf")); } else { System.out.println("Open is not supported"); } System.out.println("date"); } catch (Exception ex) { System.out.println("qsdqs"); } }
From source file:application.OfferWindow_Controller.java
@SuppressWarnings("deprecation") public void angebot_erstellen() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException, FileNotFoundException, DocumentException { idangebot++;//from w ww .j a v a 2 s. c om fikusString = fikusText.getText(); perkusidtext = Integer.parseInt(perkusid.getText()); standortnametext = standortname.getText(); rabatttext = Integer.parseInt(rabatt.getText()); mengetext = Integer.parseInt(menge.getText()); gueltigkeit = Date.valueOf(todayplus30); java.sql.Connection conn = Connection.connecten(); String query3 = "SELECT * FROM Perkus WHERE idPerkus='" + perkusnametext + "'"; PreparedStatement stmt3 = conn.prepareStatement(query3); ResultSet set = stmt3.executeQuery(); while (set.next()) { customer = new PeopleCustomers(idangebot, set.getString(2), query3, query3, query3, query3, query3, query3, query3, query3, query3, query3, idangebot, idangebot); } String perkusnametext = customer.getname(); int idPerkus = perkusidtext; // PDF create step 1 // Using a custom page size /** Path to the resulting PDF file. */ final String RESULT = "./Offer_" + perkusnametext + ".pdf"; // step 2 PdfWriter.getInstance(document, new FileOutputStream(RESULT)); ; // step 3 document.open(); document.addTitle("Offer"); document.addCreationDate(); document.add(new Paragraph( "Created: " + today.getDayOfMonth() + "." + today.getMonthValue() + "." + today.getYear(), new Font(Font.FontFamily.HELVETICA, 9, Font.ITALIC))); document.add(new Paragraph(" ")); // step 4 document.add(new Paragraph("Sample Company", new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD))); document.add(new Paragraph("Street House No.", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("D-12345 City", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("Telephone: 069-12345678, Fax: 069-23456789", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("E-Mail: sampleCompany@email.de", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("http://www.sampleCompany.de", new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph(" ")); Paragraph paragraph = new Paragraph("To Customer:", new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD)); document.add(paragraph); document.add(new Paragraph("People Customer: " + fikusnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add( new Paragraph("Corporate Customer: " + perkusnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph("Location: " + standortnametext, new Font(Font.FontFamily.HELVETICA, 9))); document.add(new Paragraph(" ")); Paragraph paragraph1 = new Paragraph("Offer " + idangebot, new Font(Font.FontFamily.HELVETICA, 20, Font.BOLDITALIC, BaseColor.BLUE)); document.add(paragraph1); document.add(new Paragraph(" ")); document.add(new Paragraph("Dear Sir or Madam, \n" + "attached you receive the following offer: \n", new Font(Font.FontFamily.HELVETICA, 13, Font.ITALIC))); document.add(new Paragraph(" ")); postion_hinzufuegen(); float preistextRabatt = erstesprodukt + zweitesprodukt; document.add(new Paragraph("Total price with discount: " + f.format(preistextRabatt) + "EUR", new Font(Font.FontFamily.HELVETICA, 15, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); if (size >= 2) { document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); } document.add(new Paragraph( "Terms and Conditions:, \n" + "- The Sample Company license terms are valid. \n" + "- All prices are quoted in addition of sales tax.\n" + "- Payment follows 30 days net. This offer is non-binding and is valid until " + +todayplus30.getDayOfMonth() + "." + todayplus30.getMonthValue() + "." + today.getYear(), new Font(Font.FontFamily.HELVETICA, 11, Font.ITALIC))); document.add(new Paragraph(" ")); document.add(new Paragraph("With kind regards,", new Font(Font.FontFamily.HELVETICA, 13))); document.add(new Paragraph("Sample Company", new Font(Font.FontFamily.HELVETICA, 13))); document.add(new Paragraph("Sample Company employee", new Font(Font.FontFamily.HELVETICA, 13))); // step 5 document.close(); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Information"); alert.setHeaderText(null); alert.setContentText("The Offer PDF has been created!"); alert.showAndWait(); String query7 = "INSERT INTO Angebot(idAngebot,Produktname,Gesamtpreis,Rabatt,gueltig_bis,Perkus_idPerkus)" + "values('" + idangebot + "','" + produktnametext + "','" + preistextRabatt + "','" + rabatttext + "','" + gueltigkeit + "','" + idPerkus + "')"; PreparedStatement stmt7 = conn.prepareStatement(query7); stmt7.executeUpdate(); }
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 a2 s. 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:BUS.ExportPDF.java
public boolean ExportPN(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/*from www . j a v a 2 s . c o m*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "PhieuNhap_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(7); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M phiu nhp", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("M Nhn Vin", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); PdfPCell c6 = new PdfPCell(new Phrase("Nh cung cp", f)); t.addCell(c6); PdfPCell c7 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c7); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(al.get(i)[1]); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); t.addCell(new Phrase(al.get(i)[4], f)); t.addCell(al.get(i)[5]); } document.add(t); // ?ng File document.close(); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportPX(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {//from ww w .j a va 2 s.co m // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "PhieuXuat_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(5); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M phiu xut", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("M Nhn Vin", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(al.get(i)[1]); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); } document.add(t); // ?ng File document.close(); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportHD(ArrayList<String[]> al) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {//from w ww . j a va 2s . c om // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "Hoadon_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Data PdfPTable t = new PdfPTable(6); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M ha n", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Tn khch hng", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tn Nhn Vin", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Ngy lp", f)); t.addCell(c5); PdfPCell c6 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c6); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(new Phrase(al.get(i)[1], f)); t.addCell(new Phrase(al.get(i)[2], f)); t.addCell(al.get(i)[3]); t.addCell(al.get(i)[4]); } document.add(t); // ?ng File document.close(); System.out.println("Write file succes!"); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportTKDT(ArrayList<String[]> al, String year) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {/*from ww w .j av a 2s .c om*/ // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "ThongKeDoanhThu_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Nam can bao cao Paragraph title2 = new Paragraph(year, FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title2); //Chart Image image = Image.getInstance("src\\Library\\barChart3D.jpeg"); image.scaleToFit(500, 400); document.add(new Paragraph()); document.add(image); //Data PdfPTable t = new PdfPTable(4); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("Thng", f)); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("Doanh thu", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Ti?n n", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Li", f)); t.addCell(c4); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(al.get(i)[1]); t.addCell(al.get(i)[2]); } document.add(t); // ?ng File document.close(); System.out.println("Write file succes!"); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:BUS.ExportPDF.java
public boolean ExportTKSP(ArrayList<String[]> al, String year) throws BadElementException, IOException, DocumentException { // To i tng ti liu Document document = new Document(PageSize.A4, 50, 50, 50, 50); File fontFile = new File("src\\Helper\\arialuni.ttf"); BaseFont unicode = BaseFont.createFont(fontFile.getAbsolutePath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font f = new Font(unicode, 12); try {//from ww w . java 2 s.com // To i tng PdfWriter Date d = new Date(); SimpleDateFormat ft = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss"); String s = "ThongKeSanPham_" + ft.format(d) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(s)); // M file thc hin ghi document.open(); Paragraph title1 = new Paragraph("CO's BAKERY", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title1); //Logo Group Image image1 = Image.getInstance("src\\Library\\cao.png"); document.add(new Paragraph()); document.add(image1); //Nm c bo co Paragraph title2 = new Paragraph(year, FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(title2); //Chart Image image = Image.getInstance("src\\Library\\pie_Chart3D.jpeg"); image.scaleToFit(500, 400); document.add(new Paragraph()); document.add(image); //Data PdfPTable t = new PdfPTable(5); t.setSpacingBefore(25); t.setSpacingAfter(25); PdfPCell c1 = new PdfPCell(new Phrase("STT")); t.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("M sn phm", f)); t.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Tn sn phm", f)); t.addCell(c3); PdfPCell c4 = new PdfPCell(new Phrase("Tng s lng", f)); t.addCell(c4); PdfPCell c5 = new PdfPCell(new Phrase("Tng ti?n", f)); t.addCell(c5); for (int i = 0; i < al.size(); i++) { Object ob = i + 1; t.addCell(ob.toString()); t.addCell(al.get(i)[0]); t.addCell(new Phrase(al.get(i)[1], f)); t.addCell(al.get(i)[2]); t.addCell(al.get(i)[3]); } document.add(t); // ?ng File document.close(); System.out.println("Write file succes!"); } catch (FileNotFoundException | DocumentException e) { return false; } return true; }
From source file:bussiness.ReportHandler.java
private void BuildHeaderPrescription(Document veterinaryPrescription, String clientName, String petName) throws DocumentException, IOException { BaseFont baseFont = BaseFont.createFont("Cookie.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED); Font font = new Font(baseFont); font.setStyle(Font.BOLDITALIC); font.setSize(35);//from w w w. j a va2 s.c o m Doctor doctor = SessionManager.getLoggedDoctor(); Paragraph p1 = new Paragraph("Dr. " + doctor.getName(), font); p1.setAlignment(Element.ALIGN_CENTER); veterinaryPrescription.add(p1); // veterinaryPrescription.add(new Chunk("\n")); Font font2 = new Font(); font2.setSize(20); Paragraph p2 = new Paragraph("CEDULA PROFESIONAL " + doctor.getIdentityCard(), font2); p2.setAlignment(Element.ALIGN_CENTER); veterinaryPrescription.add(p2); veterinaryPrescription.add(new Chunk("\n")); Paragraph p3 = new Paragraph("Nombre del cliente: " + clientName, font2); veterinaryPrescription.add(p3); Paragraph p4 = new Paragraph("Nombre de la mascota: " + petName, font2); veterinaryPrescription.add(p4); }