List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java
License:Apache License
private List<Talk> createProgrammePages() throws DocumentException, IOException { List<Talk> talksToExplain = new ArrayList<>(); document.setPageSize(PageSize.A4);/* w w w. j a v a2 s. co m*/ Font font = new Font(); font.setStyle(Font.BOLD); font.setSize(14); for (String date : service.getDates()) { for (String room : service.getRooms(date)) { Set<String> tracksInPage = new HashSet<>(); Map<String, Talk> precedentTalk = new HashMap<>(); PdfPTable table = createBeginningOfPage(font, date, room); for (String creneau : service.getCreneaux().get(date)) { PdfPCell cellCreneau = new PdfPCell(); cellCreneau.setPaddingBottom(10); Paragraph startTime = new Paragraph(creneau); startTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(startTime); Paragraph endTime = new Paragraph(getEndTime(date, creneau)); endTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(endTime); table.addCell(cellCreneau); PdfPCell cell = new PdfPCell(); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_LEFT); Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room); if (talk != null) { talksToExplain.add(talk); remplirCellWithTalk(cell, talk); cell.setRowspan(getRowSpan(date, talk)); precedentTalk.put(room, talk); tracksInPage.add(talk.getTrack()); table.addCell(cell); } else { talk = precedentTalk.get(room); if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) { table.addCell(cell); } } } document.add(table); addLegend(tracksInPage); } } return talksToExplain; }
From source file:frames.main.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { try {//from w w w. j a va 2s. c o m BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0)); Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33)); Font font1004 = new Font(unicode, 18, Font.BOLD, new BaseColor(139, 0, 0)); Font font1009 = new Font(unicode, 10, Font.NORMAL, new BaseColor(139, 10, 20)); Font font1005 = new Font(unicode, 18, Font.UNDERLINE, new BaseColor(101, 67, 33)); Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33)); // Rectangle rect=new RectangleReadOnly(590, 470, 0); ///////////////////////////////////// Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION-FORM.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE); Font font110 = new Font(Font.FontFamily.COURIER, 14, Font.NORMAL, BaseColor.GREEN); Font font11 = new Font(Font.FontFamily.COURIER, 12, Font.NORMAL, BaseColor.GREEN); com.itextpdf.text.Image image2 = com.itextpdf.text.Image .getInstance("C:\\smart kid\\src\\frames\\logo.jpg"); image2.scaleAbsolute(115f, 115f); image2.setAbsolutePosition(3, 716); Paragraph p = new Paragraph(); document.add(image2); document.add(new Chunk(" ", font1004)); document.add(new Chunk("ADMISSION FORM", font1005)); document.add(new Paragraph(" SMART KIDS CONVENT SCHOOL", font1004)); document.add(new Paragraph( " Managed By:The Smart Kids Educational Society,")); document.add(new Paragraph( " Reg.No:-00169")); document.add(new Paragraph( " 413A/23,HEERA NAGAR,GURGAON")); document.add(new Paragraph( " MOB:-9911752900 , 9891929835")); document.add(new Paragraph( " Reg.No" + " " + Rtf8.getText())); document.add(new Paragraph( "Admission No." + " " + new Date().toString())); document.add(new Paragraph(" ")); Paragraph p1 = new Paragraph(); p1.add(new Chunk("Certified that " + "Son/Daughter of:", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p1.add(new Chunk(Rtf1.getText(), font11)); document.add(p1); document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.add(new Chunk("Father's Name :" + Rtf2.getText() + "Mob:-", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p2.add(new Chunk(Rtf2.getText(), font11)); document.add(p2); document.add(new Paragraph(" ")); Paragraph p3 = new Paragraph(); p3.add(new Chunk("Mother's Name :" + Rtf2.getText() + "Mob:-", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p3.add(new Chunk(Rtf2.getText(), font11)); document.add(p3); document.add(new Paragraph(" ")); Paragraph p4 = new Paragraph(); p4.add(new Chunk("His/Her Date of birth :" + Rtf2.getText() + "Age", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p4.add(new Chunk(Rtf2.getText(), font11)); document.add(p4); document.add(new Paragraph(" ")); Paragraph p5 = new Paragraph(); p5.add(new Chunk("Corrosponding Address :", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p5.add(new Chunk("", font11)); document.add(p5); document.add(new Paragraph(" ")); Paragraph p6 = new Paragraph(); p6.add(new Chunk("Parmanent Address :", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p6.add(new Chunk("", font11)); document.add(p6); document.add(new Paragraph(" ")); Paragraph p7 = new Paragraph(); p7.add(new Chunk("Previous School & result :", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p7.add(new Chunk("He/She Wants Admmisiion in", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); document.add(p7); document.add(new Paragraph(" ")); Paragraph p8 = new Paragraph(); p8.add(new Chunk("Smart Kids Convent School in :", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p8.add(new Chunk("Class.He/She will always be regular and punctual to school.", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); document.add(p8); document.add(new Paragraph(" ")); Paragraph p9 = new Paragraph(); p9.add(new Chunk("Please admit him/her :" + "Signature", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); p9.add(new Chunk( " in" + "Class" + "Parents/Guardian", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); document.add(p9); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( " Principal(Signature) Permission of Director", FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("NOTE:- FEES WILL NOT BE REFUNDED AFTER ADMISSION.")); cb.saveState(); cb.setColorStroke(BaseColor.BLACK); cb.rectangle(2, 2, 588, 826); cb.stroke(); cb.restoreState(); JOptionPane.showMessageDialog(this, "receipt printed.."); document.close(); ; } catch (Exception ee) { JOptionPane.showMessageDialog(this, ee); } }
From source file:frames.main.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { if (PRINTMODE.getSelectedIndex() == 0) { try {/*from w w w .j ava 2 s . c om*/ //mrpno=Integer.parseInt(DTFrpno.getText()); BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0)); Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33)); Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0)); Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0)); Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33)); Rectangle rect = new RectangleReadOnly(590, 470, 0); ///////////////////////////////////// Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION.pdf")); document.setPageSize(rect); document.open(); // PdfContentByte cb = writer.getDirectContent(); Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE); com.itextpdf.text.Image image2 = com.itextpdf.text.Image .getInstance("C:\\smart kid\\src\\frames\\logo.jpg"); image2.scaleAbsolute(115f, 115f); image2.setAbsolutePosition(2, 350); document.add(image2); document.add(new Chunk( " ", font100)); document.add(new Chunk("RECEIPT", font1005)); //document.add(p); // document.add(new Paragraph( )); document.add(new Paragraph( " SMART KID CONVENT SCHOOL ", font1003)); // document.add(new Chunk(" SMART KID CONVENT SCHOOL ",font1003)); // document.add(new Chunk(" 413A/23,HEERA NAGAR GURGAON. ",font100)); document.add(new Paragraph( " 413A/23,HEERA NAGAR GURGAON. ", font100)); // document.add(new Chunk(" ph:9911752900,9891929835 ",font100)); document.add(new Paragraph( " ph:9911752900,9891929835 ", font100)); // document.add(new Chunk(" E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY))); document.add(new Paragraph(" E-mail:info.smartkids@gmail.com", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY))); document.add(new Paragraph(" ")); PdfPTable table1 = new PdfPTable(4); PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS")); c.setColspan(4); c.setBackgroundColor(BaseColor.GREEN); c.setHorizontalAlignment(Element.ALIGN_CENTER); table1.addCell(c); table1.addCell("Student Name:"); table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)))); table1.addCell("Class:"); table1.addCell(new Paragraph((String) Dtf5.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); table1.addCell("Section:"); table1.addCell(new Paragraph((String) Dtf22.getText() + " " + "Phone.:" + Dtf20.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); table1.addCell("Registration No:"); table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)))); table1.addCell("Session:"); table1.addCell(new Paragraph("NA", FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); table1.addCell("Month:"); table1.addCell(new Paragraph((String) Djc1.getSelectedItem(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f }; table1.setWidths(ColumnWidths1); table1.setWidthPercentage(113); document.add(table1); // document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(5); PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION")); cc.setBackgroundColor(BaseColor.GREEN); cc.setHorizontalAlignment(Element.ALIGN_CENTER); cc.setColspan(5); table.addCell(cc); PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell91 = new PdfPCell(new Paragraph("Cash", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell93 = new PdfPCell(new Paragraph("Total", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell99); table.addCell(cell90); table.addCell(cell91); table.addCell(cell92); table.addCell(cell93); table.addCell("1"); PdfPCell cell1 = new PdfPCell(new Paragraph("Registration Fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell1); table.addCell(Dtf11.getText()); table.addCell(" "); table.addCell(" "); table.addCell("2"); PdfPCell cell2 = new PdfPCell(new Paragraph("Admission/Re admission fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell2); table.addCell(Dtf12.getText()); table.addCell(" "); table.addCell(" "); table.addCell("3"); PdfPCell cell3 = new PdfPCell(new Paragraph("Building fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell3); table.addCell(Dtf13.getText()); table.addCell(" "); table.addCell(" "); table.addCell("4"); PdfPCell cell4 = new PdfPCell(new Paragraph("Annual Charge", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell4); table.addCell(Dtf14.getText()); table.addCell(" "); table.addCell(" "); table.addCell("5"); PdfPCell cell14 = new PdfPCell(new Paragraph("Security (Refundable)", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell14); table.addCell(Dtf17.getText()); table.addCell(" "); table.addCell(" "); table.addCell("6"); PdfPCell cell5 = new PdfPCell(new Paragraph("Tution", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell5); table.addCell(Dtf6.getText()); table.addCell(" "); table.addCell(" "); table.addCell("7"); PdfPCell cell6 = new PdfPCell(new Paragraph("Total pupils fund", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell6); table.addCell(Dtf16.getText()); table.addCell(" "); table.addCell(" "); table.addCell("8"); PdfPCell cell7 = new PdfPCell(new Paragraph("Computer Fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell7); table.addCell(Dtf7.getText()); table.addCell(" "); table.addCell(" "); table.addCell("9"); PdfPCell cell8 = new PdfPCell(new Paragraph("Sports Fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell8); table.addCell(Dtf15.getText()); table.addCell(" "); table.addCell(" "); table.addCell("10"); PdfPCell cell9 = new PdfPCell(new Paragraph("House exam Fee", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell9); table.addCell(Dtf8.getText()); table.addCell(" "); table.addCell(" "); table.addCell("11"); PdfPCell cell10 = new PdfPCell(new Paragraph("Conveyance Charge", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell10); table.addCell(Dtf18.getText()); table.addCell(" "); //table.addCell(" "); table.addCell(""); PdfPCell cell12 = new PdfPCell(new Paragraph("12", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK))); PdfPCell cell13 = new PdfPCell(new Paragraph("Grand Total", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK))); table.addCell(cell12); table.addCell(cell13); table.addCell( String.valueOf((Integer.parseInt(Dtf11.getText())) + (Integer.parseInt(Dtf12.getText())) + (Integer.parseInt(Dtf13.getText())) + (Integer.parseInt(Dtf14.getText())) + (Integer.parseInt(Dtf17.getText())) + (Integer.parseInt(Dtf6.getText())) + (Integer.parseInt(Dtf16.getText())) + (Integer.parseInt(Dtf7.getText())) + (Integer.parseInt(Dtf15.getText())) + (Integer.parseInt(Dtf8.getText())) + (Integer.parseInt(Dtf18.getText())) + (Integer.parseInt(Dtf9.getText())))); float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f }; table.setWidths(ColumnWidths); table.setWidthPercentage(113); table.completeRow(); document.add(table); document.add(new Chunk( "# Fee once paid is not refundable . For Smart kid convent school Signature ")); //document.add(new Chunk("# The monthly fee has to be deposited before 10th of every month Signature ")); JOptionPane.showMessageDialog(this, "receipt printed.."); Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1)); document.close(); ; } catch (Exception ee) { JOptionPane.showMessageDialog(this, ee); } } else if (PRINTMODE.getSelectedIndex() == 1) { try { //mrpno=Integer.parseInt(DTFrpno.getText()); BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0)); Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33)); Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0)); Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0)); Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33)); Rectangle rect = new RectangleReadOnly(590, 460, 0); ///////////////////////////////////// Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Feeslipp(MONTHLY).pdf")); document.setPageSize(rect); document.open(); // PdfContentByte cb = writer.getDirectContent(); Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE); com.itextpdf.text.Image image2 = com.itextpdf.text.Image .getInstance("C:\\smart kid\\src\\frames\\logo.jpg"); image2.scaleAbsolute(115f, 115f); image2.setAbsolutePosition(2, 350); document.add(image2); Paragraph p = new Paragraph(); p.add(new Chunk(" ")); //p.add(new Chunk("RECEIPT",font1005)); //document.add(p); document.add(new Chunk(" RECEIPT", font1003)); document.add(new Paragraph(" SMART KID CONVENT SCHOOL ", font1003)); // document.add(new Chunk(" SMART KID CONVENT SCHOOL ",font1003)); // document.add(new Chunk(" 413A/23,HEERA NAGAR GURGAON. ",font100)); document.add(new Paragraph( " 413A/23,HEERA NAGAR GURGAON. ", font100)); // document.add(new Chunk(" ph:9911752900,9891929835 ",font100)); document.add(new Paragraph( " ph:9911752900,9891929835 ", font100)); // document.add(new Chunk(" E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY))); document.add(new Paragraph(" E-mail:info.smartkids@gmail.com", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY))); document.add(new Paragraph(" ")); PdfPTable table1 = new PdfPTable(4); PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS")); c.setColspan(4); c.setBackgroundColor(BaseColor.GREEN); c.setHorizontalAlignment(Element.ALIGN_CENTER); table1.addCell(c); table1.addCell("Student Name:"); table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)))); table1.addCell("Class:"); table1.addCell(new Paragraph(Dtf5.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); table1.addCell("Section:"); table1.addCell(new Paragraph(Dtf21.getText() + " " + "Phone.:" + Dtf20.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); table1.addCell("Registration No:"); table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)))); table1.addCell("Month:"); table1.addCell(new Paragraph((String) Djc1.getSelectedItem(), FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))); float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f }; table1.setWidths(ColumnWidths1); table1.setWidthPercentage(113); document.add(table1); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(5); PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION")); cc.setBackgroundColor(BaseColor.GREEN); cc.setHorizontalAlignment(Element.ALIGN_CENTER); cc.setColspan(5); table.addCell(cc); PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell91 = new PdfPCell(new Paragraph("Cash", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); PdfPCell cell93 = new PdfPCell(new Paragraph("Total", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell99); table.addCell(cell90); table.addCell(cell91); table.addCell(cell92); table.addCell(cell93); table.addCell("1"); PdfPCell cell1 = new PdfPCell(new Paragraph("TUITION FEE", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell1); table.addCell(Dtf6.getText()); table.addCell(" "); table.addCell(" "); table.addCell("2"); PdfPCell cell2 = new PdfPCell(new Paragraph("COMPUTER FEE", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell2); table.addCell(Dtf7.getText()); table.addCell(" "); table.addCell(" "); table.addCell("3"); PdfPCell cell5 = new PdfPCell(new Paragraph("HOUSE EXAM FEE", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell5); table.addCell(Dtf8.getText()); table.addCell(" "); table.addCell(" "); table.addCell("4"); PdfPCell cell6 = new PdfPCell(new Paragraph("FINES", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell6); table.addCell(Dtf9.getText()); table.addCell(" "); table.addCell(" "); table.addCell("5"); PdfPCell cell7 = new PdfPCell(new Paragraph("OTHERS", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK))); table.addCell(cell7); table.addCell(Dtf10.getText()); table.addCell(" "); table.addCell(""); PdfPCell cell9 = new PdfPCell(new Paragraph("6", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK))); PdfPCell cell8 = new PdfPCell(new Paragraph("Grand Total", FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK))); table.addCell(cell7); table.addCell(cell8); table.addCell(String.valueOf((Integer.parseInt(Dtf6.getText())) + (Integer.parseInt(Dtf7.getText())) + (Integer.parseInt(Dtf8.getText())) + (Integer.parseInt(Dtf9.getText())) + (Integer.parseInt(Dtf10.getText())))); float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f }; table.setWidths(ColumnWidths); table.setWidthPercentage(113); table.completeRow(); document.add(table); document.add(new Chunk( "# Fee once paid is not refundable . For smart kid convent School ")); document.add(new Chunk( "# The monthly fee has to be deposited before 10th of every month Signature ")); JOptionPane.showMessageDialog(this, "receipt printed.."); Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1)); document.close(); ; } catch (Exception ee) { JOptionPane.showMessageDialog(this, ee); } } // TODO add your handling code here: }
From source file:frames.main.java
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) { try {/*from w ww . j a va 2s . c o m*/ BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // Font font11113 = new Font(unicode, 16, Font.BOLD,BaseColor(2,2,2)); ///////////////////////////////////////////////dark brown////////////////////////////////////////////////////// Font font1003 = new Font(unicode, 16, Font.BOLD, new BaseColor(101, 67, 33)); Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33)); ///////////////////////////////////// ///////////////////////////////////////////////dark red////////////////////////////////////////////////////// Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0)); Font font1005 = new Font(unicode, 14, Font.BOLD, new BaseColor(255, 0, 0)); ///////////////////////////////////// Font font100 = new Font(unicode, 8, Font.ITALIC, BaseColor.BLUE); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SMART-TC.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE); com.itextpdf.text.Image image2 = com.itextpdf.text.Image .getInstance("C:\\smart kid\\src\\frames\\logo.jpg"); image2.scaleAbsolute(125f, 125f); image2.setAbsolutePosition(31, 700); document.add(image2); com.itextpdf.text.Image ing = com.itextpdf.text.Image.getInstance("C:\\smart kid\\src\\frames\\BC.jpg"); ing.setAbsolutePosition(1, 200); document.add(ing); Font font1111 = new Font(unicode, 16, Font.BOLD, BaseColor.ORANGE); Font font11111 = new Font(unicode, 14, Font.BOLD, BaseColor.ORANGE); java.awt.Font awtPlainFont = new java.awt.Font("ALGERIAN", java.awt.Font.PLAIN, 10); document.add(new Paragraph(" SMART KIDS CONVENT SCHOOL", font1008)); document.add(new Paragraph( " HEERA NAGAR (GURGAON) ", font1003)); document.add( new Chunk(" SCHOLOR'S REGISTER AND TRANSFER CERTIFICATE", font1005)); document.add(new Paragraph(" ")); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ", font111)); Font font41 = new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD, new BaseColor(0, 0, 0)); Font font23 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, new BaseColor(92, 64, 51)); Font font1 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font font11 = new Font(Font.FontFamily.HELVETICA, 12, Font.ITALIC, new BaseColor(148, 0, 211)); Font font31 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(990000)); Font font2 = new Font(Font.FontFamily.COURIER, 18, Font.ITALIC | Font.UNDERLINE); Font font3 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(255, 255, 200)); document.add(new Paragraph( "Ref No: " + TC16.getText() + " " + new java.util.Date().toString(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); String ho4 = TC1.getText(); Paragraph p1 = new Paragraph(); p1.add(new Chunk("NAME OF STUDENT :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p1.add(new Chunk(ho4, font11)); document.add(p1); String ho5 = TC2.getText(); Paragraph p2 = new Paragraph(); p2.add(new Chunk("FATHER'S NAME :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p2.add(new Chunk(ho5, font11)); document.add(p2); String ho6 = TC3.getText(); Paragraph p93 = new Paragraph(); p93.add(new Chunk("MOTHER'S NAME :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p93.add(new Chunk(ho6, font11)); document.add(p93); Font font15 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0)); String ho8 = TC1.getText(); String tt = TC4.getText(); Paragraph p4 = new Paragraph(); p4.add(new Chunk("RELIGION :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p4.add(new Chunk(tt, font11)); document.add(p4); // document.add(new Paragraph(" ",font1003)); String kk = TC5.getText(); Paragraph p5 = new Paragraph(); p5.add(new Chunk("CASTE OF SCHOLOR :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p5.add(new Chunk(kk, font11)); document.add(p5); String ho10 = TC10.getText(); Paragraph p6 = new Paragraph(); p6.add(new Chunk("ADDRESS :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p6.add(new Chunk(ho10, font11)); document.add(p6); Paragraph p8 = new Paragraph(); p8.add(new Chunk("DATE OF BIRTH :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p8.add(new Chunk(TC9.getText(), font11)); document.add(p8); Paragraph p9 = new Paragraph(); p9.add(new Chunk("SECTION :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p9.add(new Chunk(TC7.getText(), font11)); document.add(p9); Paragraph p10 = new Paragraph(); p10.add(new Chunk("REGISTRATION NO: :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p10.add(new Chunk(TC8.getText(), font11)); document.add(p10); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(8); String vacume = ""; table.addCell("Class"); table.addCell("Date of Admission"); table.addCell("Date of Promotion"); table.addCell("Date of Removal"); table.addCell("Cause of Removal"); table.addCell("Year"); table.addCell("Conduct and Work"); table.addCell("Sign"); PdfPCell cell10 = new PdfPCell(new Paragraph("NURSERY", font100)); table.addCell(cell10); if (TC6.getSelectedIndex() == 0) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell111 = new PdfPCell(new Paragraph("LKG", font100)); table.addCell(cell111); if (TC6.getSelectedIndex() == 1) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell1 = new PdfPCell(new Paragraph("UKG", font100)); table.addCell(cell1); if (TC6.getSelectedIndex() == 2) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell2 = new PdfPCell(new Paragraph("STD-1", font100)); table.addCell(cell2); if (TC6.getSelectedIndex() == 3) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell3 = new PdfPCell(new Paragraph("STD-2", font100)); table.addCell(cell3); if (TC6.getSelectedIndex() == 4) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell4 = new PdfPCell(new Paragraph("STD-3", font100)); table.addCell(cell4); if (TC6.getSelectedIndex() == 5) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell5 = new PdfPCell(new Paragraph("STD-4", font100)); table.addCell(cell5); if (TC6.getSelectedIndex() == 6) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell6 = new PdfPCell(new Paragraph("STD-5", font100)); table.addCell(cell6); if (TC6.getSelectedIndex() == 7) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell8 = new PdfPCell(new Paragraph("STD-6", font100)); table.addCell(cell8); if (TC6.getSelectedIndex() == 8) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell9 = new PdfPCell(new Paragraph("STD-7", font100)); table.addCell(cell9); if (TC6.getSelectedIndex() == 9) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell18 = new PdfPCell(new Paragraph("STD-8", font100)); table.addCell(cell18); if (TC6.getSelectedIndex() == 2) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } float[] ColumnWidths = new float[] { 8f, 12f, 12f, 12f, 22f, 8f, 15f, 7f }; table.setWidths(ColumnWidths); table.setWidthPercentage(106); table.setHorizontalAlignment(Element.ALIGN_LEFT); document.add(table); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "1. I certified that the entries as regard details of the student have been duly checked from the 'Admission form' and that they are complete.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); // document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "2. Certified that the above Students register have been posted up-to date of students leaving as required by the departmental rules.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "Prepared by:-" + " " + "Date:-" + " " + new java.util.Date().toString() + " " + "Principal's Sign:-", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("An ISO 9001:2008 Certified School(Certificate Number:NOR/0712M/1505)", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE))); document.add(new Paragraph("(Run By:Smart Educational Society)Regd.No.(DR/GGN/285)", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE))); document.add(new Paragraph( "413A/23,Gali No:-2,Heera Nagar,Near Rajendra Hospital,Khandsa Road,Gurgaon(Haryana)", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLUE))); cb.saveState(); cb.setColorStroke(BaseColor.BLACK); cb.rectangle(2, 2, 588, 828); cb.stroke(); cb.restoreState(); JOptionPane.showMessageDialog(this, "it is saved"); document.close(); } catch (Exception ee) { JOptionPane.showMessageDialog(this, ee); } // TODO add your handling code here: }
From source file:Funciones.TicketPDF.java
PdfPTable tablaHeader() throws IOException, BadElementException { PdfPTable tablaheader = new PdfPTable(4); tablaheader.setTotalWidth(600);/*from w ww. j a v a2s .co m*/ BasededatosManager bd = new BasededatosManager(); try { ResultSet consulta = bd.consultar("SELECT logoempresa FROM configuracion"); byte[] arreglo = null; while (consulta.next()) { arreglo = consulta.getBytes("logoempresa"); } Image logo = Image.getInstance(arreglo); logo.scalePercent(15); PdfPCell celdalogo = new PdfPCell(logo); celdalogo.setBorderColor(BaseColor.WHITE); celdalogo.setColspan(4); celdalogo.setHorizontalAlignment(Element.ALIGN_CENTER); tablaheader.addCell(celdalogo); } catch (SQLException ex) { Logger.getLogger(PedidoPDF.class.getName()).log(Level.SEVERE, null, ex); } Font a = new Font(FontFamily.HELVETICA, 18, Font.BOLD, BaseColor.BLACK); PdfPCell celdatitulo = new PdfPCell(new Paragraph("PEDIDO PIZZAS", a)); celdatitulo.setColspan(2); celdatitulo.setBorderColor(BaseColor.WHITE); tablaheader.addCell(celdatitulo); PdfPCell celdafecha = new PdfPCell(new Paragraph("Fecha: " + LocalDate.now(), f)); celdafecha.setBorderColor(BaseColor.WHITE); tablaheader.addCell(celdafecha); PdfPCell celdapedido = new PdfPCell(new Paragraph("N Pedido: " + idpedido, f)); celdapedido.setBorderColor(BaseColor.WHITE); tablaheader.addCell(celdapedido); vacio.setColspan(4); vacio.setBorder(Rectangle.BOTTOM); tablaheader.addCell(vacio); return tablaheader; }
From source file:fxml.test.PDFService.java
private PdfPTable createDocumentHeader() throws IOException, BadElementException { //start creating header for the document...... PdfPTable headerTable = new PdfPTable(3); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*from w ww. j a va2 s . c o m*/ headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f }); headerTable.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg")); image.scalePercent(42f); image.setAlignment(Element.ALIGN_LEFT); PdfPCell imageCell = new PdfPCell(image, false); imageCell.setPaddingTop(6); imageCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(imageCell); //start info table..... PdfPTable infoTable = new PdfPTable(1); infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH"; String tabulationText = "TABULATION SHEET"; String deptText = inputs.get(0).trim(); String s1 = inputs.get(1).trim(); String s2 = inputs.get(2).trim(); String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2); String session = inputs.get(3).trim(); String date = inputs.get(4).trim(); String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date); infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true)); infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); //end info table..... PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(infoCell); PdfPCell resultPublishDateCell = new PdfPCell( new Paragraph("Result Published On............................", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD))); resultPublishDateCell.setBorder(Rectangle.NO_BORDER); resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(resultPublishDateCell); headerTable.setSpacingAfter(17.5f); // System.err.println("completed header table"); return headerTable; //end creating header for the document...... }
From source file:generators.InvoiceGenerator.java
/** * Generate Invoice pdf file//from ww w .j a v a 2 s. c om * * @param order the order * @throws DocumentException the document exception * @throws IOException the io exception */ public void generate(Order order) throws DocumentException, IOException { Date invoiceDate = order.getDate(); SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM YYYY"); // User guest = order.getGuest(); User guest = new UserDAO().get(order.getUserId()); guest.setOrder(order); System.out.println("invoice generator orderID: " + order.getId()); Document document = new Document(); Font defaultFont = new Font(Font.FontFamily.TIMES_ROMAN, 12); System.out.println(System.getProperty("user.dir")); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(System.getProperty("user.dir") + "/src/main/java/nl/ipsen3/invoice/" + new SimpleDateFormat("dd-MM-yyyy").format(invoiceDate) + " - " + order.getId() + ".pdf")); document.setMargins(30, 30, 30, 65); writer.setPageEvent(new InvoiceEventListener()); document.open(); Paragraph header = new Paragraph("Lionsclub Oegstgeest/Warmond", new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD)); header.setAlignment(Element.ALIGN_CENTER); document.add(header); AddressDAO addressDAO = new AddressDAO(); Address userAddress = addressDAO.get(guest.getAddressId()); Paragraph address = new Paragraph(guest.getFirstName() + " " + guest.getPrefixLastName() + " " + guest.getLastName() + "\n" + userAddress.getStreet() + " " + userAddress.getHouseNumber() + "\n" + userAddress.getZipCode() + " " + userAddress.getCity(), defaultFont); address.setSpacingBefore(35); address.setSpacingAfter(25); address.setLeading(15); document.add(address); Paragraph invoiceDetails = new Paragraph("Factuurdatum: " + sdf.format(invoiceDate) + "\n" + "FactuurNummer: " + order.getId() + " \n" + "Debiteurennummer: " + guest.getId(), defaultFont); invoiceDetails.setSpacingAfter(15); invoiceDetails.setLeading(15); document.add(invoiceDetails); Paragraph subject = new Paragraph("Betreft: Onderwerp factuur", defaultFont); subject.setSpacingAfter(30); document.add(subject); PdfPTable orderTable = new PdfPTable(10); PdfPCell wineCell = new PdfPCell(new Paragraph("Wijn", defaultFont)); wineCell.setColspan(5); wineCell.setBorder(Rectangle.BOTTOM); orderTable.getDefaultCell().setPaddingBottom(10); orderTable.getDefaultCell().setBorder(Rectangle.BOTTOM); ; orderTable.addCell(new Paragraph("Code", defaultFont)); orderTable.addCell(new Paragraph("Aantal", defaultFont)); orderTable.addCell(wineCell); orderTable.addCell(new Paragraph("Jaar", defaultFont)); orderTable.addCell(new Paragraph("Per Fles", defaultFont)); orderTable.addCell(new Paragraph("Bedrag", defaultFont)); orderTable.getDefaultCell().setPaddingBottom(0); orderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); wineCell.setBorder(Rectangle.NO_BORDER); NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.GERMANY); for (WineOrder wineOrder : order.getWineOrders()) { orderTable.addCell(new Paragraph("" + wineOrder.getWine().getId(), defaultFont)); orderTable.addCell(new Paragraph("" + wineOrder.getAmount(), defaultFont)); wineCell.setPhrase(new Phrase(wineOrder.getWine().getName(), defaultFont)); orderTable.addCell(wineCell); orderTable.addCell(new Paragraph("" + wineOrder.getWine().getYear(), defaultFont)); orderTable.addCell(new Paragraph( " " + numberFormat.format(wineOrder.getWine().getPrice()).replace(" ", ""), defaultFont)); orderTable.addCell(new Paragraph(" " + numberFormat .format(wineOrder.getAmount() * wineOrder.getWine().getPrice()).replace(" ", ""), defaultFont)); orderTable.completeRow(); } orderTable.addCell(" "); orderTable.completeRow(); Font totalFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); PdfPCell totalAmount = new PdfPCell( new Paragraph(" " + numberFormat.format(order.getTotalAmount()).replace(" ", ""), totalFont)); totalAmount.setBorder(Rectangle.TOP); totalAmount.setPaddingTop(10); PdfPCell totalCell = new PdfPCell(new Paragraph("Totaal", totalFont)); totalCell.setPaddingTop(10); totalCell.setBorder(Rectangle.NO_BORDER); orderTable.addCell(totalCell); PdfPCell fillerCell = new PdfPCell(new Paragraph("")); fillerCell.setColspan(8); fillerCell.setBorder(Rectangle.NO_BORDER); orderTable.addCell(fillerCell); orderTable.addCell(totalAmount); orderTable.setSpacingBefore(15); orderTable.setSpacingAfter(30); orderTable.setWidthPercentage(95); orderTable.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(orderTable); Paragraph retrievalDetails = new Paragraph( "Wij verzoeken u vriendelijk het totaalbedrag binnen 7 dagen na factuurdatum over te maken op bankrekening <bankAccountNr> t.n.v <bankAccountName> onder vermelding van het factuurnummer", defaultFont); retrievalDetails.setLeading(15); retrievalDetails.setSpacingAfter(20); document.add(retrievalDetails); // document.add(new Paragraph("U kunt uw wijnen ophalen op " + sdf.format(invoiceDate) , defaultFont)); // document.add(new Paragraph("Adres:", defaultFont)); // // PdfPTable addressTable = new PdfPTable(1); // addressTable.setSpacingBefore(5); // addressTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); // addressTable.getDefaultCell().setPaddingLeft(35); // MerchantService merchantService = new MerchantService(); // Merchant merchant = merchantService.find(merchantService.all().get(0).getId()); // addressTable.addCell(new Paragraph(merchant.getName(), defaultFont)); // addressTable.addCell(new Paragraph(merchant.getAddress().getStreet() // + " " + merchant.getAddress().getHouseNumber(), defaultFont)); // addressTable.addCell(new Paragraph(merchant.getAddress().getZipCode() + " " + // merchant.getAddress().getCity(), defaultFont)); // addressTable.setHorizontalAlignment(Element.ALIGN_LEFT); // document.add(addressTable); document.close(); System.out.println( "Succesfully generated IPSEN2.invoice: " + order.getId() + " on Date: " + sdf.format(invoiceDate)); }
From source file:gov.va.cem.eoas.business.FaxArchivesPDF.java
public InputStream generatePDF(FaxRecord data) { SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy"); Date curDate = new Date(); String caseIdData = (data.getCaseId() != null) ? data.getCaseId() : ""; String currentDate = new String(newFormat.format(curDate)); String sepDocs = (data.getSepDocs()) ? "X" : ""; String marLicense = (data.getMarLicense()) ? "X" : ""; String adminDecision = (data.getAdminDecision()) ? "X" : ""; String deathCert = (data.getDeathCert()) ? "X" : ""; String divorceDecree = (data.getDivorceDecree()) ? "X" : ""; String otherCheck = (data.getOtherCheck()) ? "X" : ""; String transDate = (data.getTransDate() != null) ? new String(newFormat.format(data.getTransDate())) : ""; String priorLoc = (data.getPriorLoc() != null) ? data.getPriorLoc() : ""; String otherComments = (data.getOtherComments() != null) ? data.getOtherComments() : ""; String remarks = (data.getRemarks() != null) ? data.getRemarks() : ""; String to = data.getTo().getDisplayName(); String fileNo = (data.getFileNo() != null) ? data.getFileNo() : ""; String vetName = (data.getVetName() != null) ? data.getVetName() : ""; String ssnData = (data.getSSN() != null) ? data.getSSN() : ""; String snData = (data.getSN() != null) ? data.getSN() : ""; String farcNo = (data.getFarcNo() != null) ? data.getFarcNo() : ""; String boxNoData = (data.getBoxNo() != null) ? data.getBoxNo() : ""; String faxPages = (data.getFaxPages() != null) ? data.getFaxPages() : ""; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4, 50, 50, 50, 50); try {/*from ww w . j a v a 2 s .c o m*/ PdfWriter.getInstance(document, outputStream); //Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 9); Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD); Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 11); Font fontBold = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD); //Font fontUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.UNDERLINE); Font fontHeader = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); document.open(); String dirPath = FacesContext.getCurrentInstance().getExternalContext() .getInitParameter("image_file_path"); // Check servlet context for invalid character if (dirPath.contains("..")) throw new IllegalArgumentException( "Servlet context contains invalid character(s). Security may have been compromised."); File dir = new File(dirPath); Image image = Image.getInstance(dir + "/ArchiveFaxHeader.jpg"); image.scalePercent(69, 66); document.add(image); // Create first table float[] colsWidthTo = { .3f, 2f, .4f, 2f }; PdfPTable addressTable = new PdfPTable(colsWidthTo); addressTable.setWidthPercentage(100); PdfPCell toLabel = new PdfPCell(new Phrase("TO:", fontBold)); toLabel.setRowspan(3); toLabel.setBorderWidthRight(0); addressTable.addCell(toLabel); PdfPCell toName = new PdfPCell(new Phrase(to, fontBold)); toName.setBorderWidthLeft(0); toName.setBorderWidthBottom(0); addressTable.addCell(toName); PdfPCell fromLabel = new PdfPCell(new Phrase("FROM:", fontBold)); fromLabel.setBorderWidthRight(0); fromLabel.setBorderWidthBottom(0); addressTable.addCell(fromLabel); PdfPCell fromName = new PdfPCell(new Phrase("Eligibility Case Manager", fontBold)); fromName.setBorderWidthBottom(0); fromName.setBorderWidthLeft(0); addressTable.addCell(fromName); PdfPCell toAddress = new PdfPCell(new Phrase("", fontBold)); toAddress.setBorderWidthLeft(0); toAddress.setBorderWidthTop(0); addressTable.addCell(toAddress); PdfPCell fromDateLabel = new PdfPCell(new Phrase("DATE:", fontBold)); fromDateLabel.setBorderWidthRight(0); fromDateLabel.setBorderWidthTop(0); //toLabel.setRowspan(2); addressTable.addCell(fromDateLabel); PdfPCell dateFrom = new PdfPCell(new Phrase(currentDate, fontBold)); dateFrom.setBorderWidthTop(0); dateFrom.setBorderWidthLeft(0); addressTable.addCell(dateFrom); addressTable.setSpacingBefore(15); addressTable.setSpacingAfter(15); document.add(addressTable); float[] colsWidthCaseId = { .7f, 3f }; PdfPTable caseTable = new PdfPTable(colsWidthCaseId); caseTable.setWidthPercentage(100); PdfPCell caseIdLabel = new PdfPCell(new Phrase("Eligibility Case Id:", font3)); caseIdLabel.setBorderWidth(0); caseTable.addCell(caseIdLabel); PdfPCell caseIdInput = new PdfPCell(new Phrase(caseIdData, font3)); caseIdInput.setBorderWidth(0); caseTable.addCell(caseIdInput); caseTable.setSpacingAfter(8); document.add(caseTable); float[] colsWidthFolder = { .5f, 3f }; PdfPTable folderTable = new PdfPTable(colsWidthFolder); folderTable.setWidthPercentage(100); PdfPCell folderLabel = new PdfPCell(new Phrase("VA file No:", font3)); folderLabel.setBorderWidth(0); folderTable.addCell(folderLabel); PdfPCell folder = new PdfPCell(new Phrase(fileNo, font3)); folder.setBorderWidth(0); folderTable.addCell(folder); folderTable.setSpacingAfter(8); document.add(folderTable); float[] colsWidthRef = { .7f, 3f }; PdfPTable refTable = new PdfPTable(colsWidthRef); refTable.setWidthPercentage(100); PdfPCell ref = new PdfPCell(new Phrase("Veteran's Name:", font3)); ref.setBorderWidth(0); refTable.addCell(ref); PdfPCell refName = new PdfPCell(new Phrase(vetName, font3)); refName.setBorderWidth(0); refTable.addCell(refName); refTable.setSpacingAfter(8); document.add(refTable); float[] colsWidthSSN = { .3f, 2f, .25f, 2f }; PdfPTable ssnTable = new PdfPTable(colsWidthSSN); ssnTable.setWidthPercentage(100); PdfPCell ssnLabel = new PdfPCell(new Phrase("SSN:", font3)); ssnLabel.setBorderWidth(0); ssnTable.addCell(ssnLabel); PdfPCell ssn = new PdfPCell(new Phrase(ssnData, font3)); ssn.setBorderWidth(0); ssnTable.addCell(ssn); PdfPCell snLabel = new PdfPCell(new Phrase("SN:", font3)); snLabel.setBorderWidth(0); ssnTable.addCell(snLabel); PdfPCell sn = new PdfPCell(new Phrase(snData, font3)); sn.setBorderWidth(0); ssnTable.addCell(sn); ssnTable.setSpacingAfter(8); document.add(ssnTable); float[] colsWidthFARC = { .6f, 2f, .8f, 2f }; PdfPTable farcTable = new PdfPTable(colsWidthFARC); farcTable.setWidthPercentage(100); PdfPCell farcLabel = new PdfPCell(new Phrase("FARC No:", font3)); farcLabel.setBorderWidth(0); farcTable.addCell(farcLabel); PdfPCell farc = new PdfPCell(new Phrase(farcNo, font3)); farc.setBorderWidth(0); farcTable.addCell(farc); PdfPCell farcDateLabel = new PdfPCell(new Phrase("Transfer Date:", font3)); farcDateLabel.setBorderWidth(0); farcTable.addCell(farcDateLabel); PdfPCell farcDate = new PdfPCell(new Phrase(transDate, font3)); farcDate.setBorderWidth(0); farcTable.addCell(farcDate); farcTable.setSpacingAfter(8); document.add(farcTable); float[] colsWidthLoc = { .8f, 2f, .6f, 2f }; PdfPTable locTable = new PdfPTable(colsWidthLoc); locTable.setWidthPercentage(100); PdfPCell locLabel = new PdfPCell(new Phrase("Prior Location:", font3)); locLabel.setBorderWidth(0); locTable.addCell(locLabel); PdfPCell location = new PdfPCell(new Phrase(priorLoc, font3)); location.setBorderWidth(0); locTable.addCell(location); PdfPCell boxNoLabel = new PdfPCell(new Phrase("Box No:", font3)); boxNoLabel.setBorderWidth(0); locTable.addCell(boxNoLabel); PdfPCell boxNo = new PdfPCell(new Phrase(boxNoData, font3)); boxNo.setBorderWidth(0); locTable.addCell(boxNo); locTable.setSpacingAfter(8); document.add(locTable); float[] colsWidthRemarks = { .6f, 5f }; PdfPTable remarks1Table = new PdfPTable(colsWidthRemarks); remarks1Table.setWidthPercentage(100); PdfPCell remark1Label = new PdfPCell(new Phrase("Remarks:", font3)); remark1Label.setBorderWidth(0); remarks1Table.addCell(remark1Label); PdfPCell remarks1Input = new PdfPCell(new Phrase( "Please provide copy(ies) of the following document(s) to establish eligibility for burial in a national cemetery.", font3)); remarks1Input.setBorderWidth(0); remarks1Table.addCell(remarks1Input); remarks1Table.setSpacingAfter(8); document.add(remarks1Table); float[] colsWidthDocs = { .4f, 2f, .4f, 2f }; PdfPTable docsTable = new PdfPTable(colsWidthDocs); docsTable.setWidthPercentage(100); PdfPCell docsLabel = new PdfPCell(new Phrase(sepDocs, font3)); docsLabel.setHorizontalAlignment(Element.ALIGN_CENTER); docsLabel.setBorderWidth(0); docsLabel.setBorderWidthBottom(1); docsTable.addCell(docsLabel); PdfPCell docs1 = new PdfPCell(new Phrase("Separation Document(s)", font3)); docs1.setBorderWidth(0); docsTable.addCell(docs1); PdfPCell docs2 = new PdfPCell(new Phrase(deathCert, font3)); docs2.setHorizontalAlignment(Element.ALIGN_CENTER); docs2.setBorderWidth(0); docs2.setBorderWidthBottom(1); docsTable.addCell(docs2); PdfPCell docs3 = new PdfPCell(new Phrase("Death Certificate", font3)); docs3.setBorderWidth(0); docsTable.addCell(docs3); PdfPCell docs4 = new PdfPCell(new Phrase(marLicense, font3)); docs4.setHorizontalAlignment(Element.ALIGN_CENTER); docs4.setBorderWidth(0); docs4.setBorderWidthBottom(1); docsTable.addCell(docs4); PdfPCell docs5 = new PdfPCell(new Phrase("Marriage License", font3)); docs5.setBorderWidth(0); docsTable.addCell(docs5); PdfPCell docs6 = new PdfPCell(new Phrase(divorceDecree, font3)); docs6.setHorizontalAlignment(Element.ALIGN_CENTER); docs6.setBorderWidth(0); docs6.setBorderWidthBottom(1); docsTable.addCell(docs6); PdfPCell docs7 = new PdfPCell(new Phrase("Divorce Decree", font3)); docs7.setBorderWidth(0); docsTable.addCell(docs7); PdfPCell docs8 = new PdfPCell(new Phrase(adminDecision, font3)); docs8.setHorizontalAlignment(Element.ALIGN_CENTER); docs8.setBorderWidth(0); docs8.setBorderWidthBottom(1); docsTable.addCell(docs8); PdfPCell docs9 = new PdfPCell(new Phrase("VA Admin Decision", font3)); docs9.setBorderWidth(0); docsTable.addCell(docs9); PdfPCell docs10 = new PdfPCell(new Phrase("", font3)); docs10.setBorderWidth(0); docsTable.addCell(docs10); PdfPCell docs11 = new PdfPCell(new Phrase("", font3)); docs11.setBorderWidth(0); docsTable.addCell(docs11); document.add(docsTable); float[] colsWidthOther = { .4f, .4f, 4f }; PdfPTable otherDocTable = new PdfPTable(colsWidthOther); otherDocTable.setWidthPercentage(100); PdfPCell otherDoc1 = new PdfPCell(new Phrase(otherCheck, font3)); otherDoc1.setHorizontalAlignment(Element.ALIGN_CENTER); otherDoc1.setBorderWidth(0); otherDoc1.setBorderWidthBottom(1); otherDocTable.addCell(otherDoc1); PdfPCell otherDoc2 = new PdfPCell(new Phrase("Other", font3)); otherDoc2.setBorderWidth(0); otherDocTable.addCell(otherDoc2); PdfPCell otherDoc3 = new PdfPCell(new Phrase("", font3)); otherDoc3.setBorderWidth(0); otherDocTable.addCell(otherDoc3); otherDocTable.setSpacingAfter(8); document.add(otherDocTable); if (!otherComments.equals("")) { float[] colsWidthOtherComments = { 1.1f, 5f }; PdfPTable otherCommentsTable = new PdfPTable(colsWidthOtherComments); otherCommentsTable.setWidthPercentage(100); PdfPCell otherCommentLabel = new PdfPCell(new Phrase("Other Comments:", font3)); otherCommentLabel.setBorderWidth(0); otherCommentsTable.addCell(otherCommentLabel); PdfPCell otherCommentsInput = new PdfPCell(new Phrase(otherComments, font3)); otherCommentsInput.setBorderWidth(0); otherCommentsTable.addCell(otherCommentsInput); otherCommentsTable.setSpacingAfter(8); document.add(otherCommentsTable); } PdfPTable remarksTable = new PdfPTable(colsWidthRemarks); remarksTable.setWidthPercentage(100); PdfPCell remarkLabel = new PdfPCell(new Phrase("Remarks:", font3)); remarkLabel.setBorderWidth(0); remarksTable.addCell(remarkLabel); PdfPCell remarksInput = new PdfPCell(new Phrase(remarks, font3)); remarksInput.setBorderWidth(0); remarksTable.addCell(remarksInput); remarksTable.setSpacingAfter(8); document.add(remarksTable); Paragraph expediteOne = new Paragraph("-- PLEASE EXPEDITE --", font3); expediteOne.setSpacingBefore(5); expediteOne.setSpacingAfter(10); document.add(expediteOne); Paragraph disclosure = new Paragraph( "This fax is intended only for the use of the person or office to which it is addressed and may contain information that is privileged, confidential, or protected by law. All others are hereby notified that the receipt of this fax does not waive any applicable privilege or exemption for disclosure and that any dissemination, distribution, or copying of this communication is prohibited. If you have received this fax in error, please notify this office immediately at the telephone number listed above.", font2); disclosure.setAlignment(Element.ALIGN_JUSTIFIED); disclosure.setSpacingBefore(5); disclosure.setSpacingAfter(10); document.add(disclosure); float[] colsWidthPages = { 5f, .5f, 2f }; PdfPTable pagesTable = new PdfPTable(colsWidthPages); pagesTable.setWidthPercentage(71); PdfPCell pageOneLabel = new PdfPCell( new Phrase("This fax sheet consists of the cover page and ", fontHeader)); pageOneLabel.setBorderWidth(0); pageOneLabel.setHorizontalAlignment(Element.ALIGN_RIGHT); pagesTable.addCell(pageOneLabel); PdfPCell pages = new PdfPCell(new Phrase(faxPages, fontHeader)); pages.setBorderWidth(0); pages.setHorizontalAlignment(Element.ALIGN_CENTER); pages.setBorderWidthBottom(1); pagesTable.addCell(pages); PdfPCell pageTwoLabel = new PdfPCell(new Phrase(" additional pages", fontHeader)); pageTwoLabel.setBorderWidth(0); pagesTable.addCell(pageTwoLabel); pagesTable.setSpacingAfter(8); document.add(pagesTable); Paragraph expediteTwo = new Paragraph("FAX: 816-268-8163 ***** BURIAL PLEASE EXPEDITE *****", fontBold); expediteTwo.setSpacingBefore(5); expediteTwo.setSpacingAfter(10); document.add(expediteTwo); document.close(); } catch (Exception ex) { System.err.println(ex.getMessage()); } return new ByteArrayInputStream(outputStream.toByteArray()); }
From source file:groove.gui.dialog.ExploreWarningDialog.java
License:Apache License
/** Lazily constructs and returns the label showing the main message. */ private JLabel getMessageLabel() { if (this.messageLabel == null) { this.messageLabel = new JLabel(); this.messageLabel.setFont(this.messageLabel.getFont().deriveFont(Font.BOLD)); this.messageLabel.setAlignmentX(Component.LEFT_ALIGNMENT); }//from w ww.ja v a 2 s. c om return this.messageLabel; }
From source file:GUI.Framenewventa.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if (jLabel17.getText().toString().equals("-")) { JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE"); } else {/*from ww w . j a v a2 s . c o m*/ try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); funciones f = new funciones(); String dia = (Calendar.getInstance().getTime().getDate() < 10) ? "0" + Calendar.getInstance().getTime().getDate() : Calendar.getInstance().getTime().getDate() + ""; String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1)); String anio = (Calendar.getInstance().getTime().getYear() + 1900) + ""; String nombre = "COTIZACION TIENDA ULTIMO ROUND"; String rut_socio = ""; int mon = 0; String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf"; DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String stringToEncrypt = nombre.trim() + dateFormat.format(date); int encryptedString = stringToEncrypt.trim().hashCode(); String aRemplazar = Integer.toString(encryptedString); String remplazado = aRemplazar.replace("-", ""); String url = f.getRutaCotizacion() + arch; FileOutputStream archivo = new FileOutputStream(url); int deuda = Integer.parseInt("1"); String palabra = f.Convertir(deuda + "", false); palabra = palabra.substring(0, palabra.length() - 2); if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones") | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) { palabra = palabra + "de pesos"; } else { palabra = palabra + "pesos"; } Document documento = new Document(PageSize.LETTER); PdfWriter.getInstance(documento, archivo); documento.open(); try { Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 400); documento.add(im); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } int linea = 0; Font fuente = new Font(); fuente.setStyle(Font.UNDERLINE | Font.BOLD); fuente.setSize(11); fuente.setColor(BaseColor.BLACK); documento.add(new Paragraph(" ")); Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); fecha.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(fecha); Paragraph obp = new Paragraph("ULTIMO ROUND\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); obp.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(obp); Paragraph codigo = new Paragraph("COD." + remplazado, FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); codigo.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(codigo); Paragraph space = new Paragraph("\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); space.setAlignment(Paragraph.ALIGN_LEFT); documento.add(space); Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen); Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen2.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen2); Paragraph a = new Paragraph(nombre, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); a.setAlignment(Paragraph.ALIGN_LEFT); documento.add(a); Paragraph rut = new Paragraph(rut_socio, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); rut.setAlignment(Paragraph.ALIGN_LEFT); documento.add(rut); Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); ref.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(ref); documento.add(space); int numerocheque = 0; int montofinal = 0; String montostring = ""; String detalle = ""; String monto = jLabel22.getText(); String montoaux = monto.replace(".", ""); deuda = Integer.parseInt(montoaux); palabra = f.Convertir(deuda + "", false); System.out.println(palabra); palabra = palabra.replaceAll("0", ""); System.out.println(palabra); Paragraph e = new Paragraph( "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos" + " por el monto de $" + monto + ".- ( " + palabra + "pesos IVA INCLUIDO) ,segn detalle:\n\n", FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK)); e.setAlignment(Paragraph.ALIGN_LEFT); documento.add(e); documento.add(new Paragraph(" ")); // ACA DEBE IR LA TABLA //special font sizes Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10); //specify column widths //create PDF table with the given widths documento.add(new Paragraph(" ")); float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f }; PdfPTable tabla = new PdfPTable(5); tabla.setWidths(colsWidth); String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" }; tabla.setWidthPercentage(100); PdfPCell celda; for (int k = 0; k < titulos.length; k++) { celda = new PdfPCell(new Paragraph(titulos[k], FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } int var = 0; int w = 0; for (w = 0; w < jTable1.getRowCount(); w++) { celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("MONTO NETO", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(monto, FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("IVA TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); double iva2 = Float.parseFloat(monto) * (0.19); iva2 = Math.round(iva2); celda = new PdfPCell(new Paragraph(Double.toString(iva2), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("VALOR TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); int valortotal = Integer.parseInt(monto); ; celda = new PdfPCell(new Paragraph(Integer.toString(valortotal), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); //FOOOTER documento.add(space); Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); despido.setAlignment(Paragraph.ALIGN_LEFT); documento.add(despido); documento.add(space); Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma2.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(firma2); documento.add(space); documento.add(space); documento.add(space); Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma3.setAlignment(Paragraph.ALIGN_CENTER); documento.add(firma3); documento.add(space); documento.add(space); try { Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 500); documento.add(im); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } documento.close(); setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } } }