List of usage examples for com.itextpdf.text RectangleReadOnly RectangleReadOnly
public RectangleReadOnly(final float urx, final float ury, final int rotation)
RectangleReadOnly
-object starting from the origin (0, 0) and with a specific rotation (valid values are 0, 90, 180, 270). From source file:frames.main.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) { if (PRINTMODE.getSelectedIndex() == 0) { try {/*from w w w. j a v a2 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: }