List of usage examples for com.itextpdf.text FontFactory COURIER
String COURIER
To view the source code for com.itextpdf.text FontFactory COURIER.
Click Source Link
From source file:containers.Report.java
public void generateOrderByPayment(String type, ArrayList<String> entry, String from, String to) { try {/*from ww w .j a v a 2 s .co m*/ String path = System.getProperty("user.home") + File.separator + "Documents"; OutputStream file = new FileOutputStream(new File(path + "\\PayTypeReport.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); Paragraph p = new Paragraph("", FontFactory.getFont(FontFactory.COURIER)); Image img = Image.getInstance(new URL(link)); img.scalePercent(56f); p.add(img); body3 = String.format("%5s - %5s - %5s\n", "Order No.", "Order Total", "Order Date"); double counter = 0; for (int i = 0; i < entry.size(); i += 3) { body3 += String.format("%-10s %8s %25s\n", entry.get(i), entry.get(i + 1), entry.get(i + 2).substring(0, 19)); counter += Double.parseDouble(entry.get(i + 1)); } body3 += "\n\nTotal for all orders: $" + counter; from = from.substring(0, 10); to = to.substring(0, 10); p.add(new Date().toString()); p.add("\n\nOrder by Payment Report\n"); p.add("Payment Type: " + type + "\n"); p.add("Reporting Date: \n" + from + " - " + to + "\n\n"); p.add(body3); document.add(p); document.close(); file.close(); body3 = ""; } catch (Exception e) { e.printStackTrace(); } }
From source file:containers.Report.java
public void generateOrderItem(String ordernum, ArrayList<String> entry) { try {/*from w ww . jav a2 s.c o m*/ String path = System.getProperty("user.home") + File.separator + "Documents"; OutputStream file = new FileOutputStream(new File(path + "\\OrderReport.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); Paragraph p = new Paragraph("", FontFactory.getFont(FontFactory.COURIER)); Image img = Image.getInstance(new URL(link)); img.scalePercent(56f); p.add(img); body4 = String.format("%5s %27s %10s\n", "Item Name", "Base Price", "Log Total"); double counter = 0; for (int i = 0; i < entry.size(); i += 3) { body4 += String.format("%-10s %15s %12s\n", entry.get(i), entry.get(i + 1), entry.get(i + 2)); counter += Double.parseDouble(entry.get(i + 2)); } body4 += "\n\nTotal for all orders: $" + counter; p.add(new Date().toString()); p.add("\n\nItems on Order Report\n"); p.add("Order Number: " + ordernum + "\n\n"); p.add(body4); document.add(p); document.close(); file.close(); body4 = ""; } catch (Exception e) { e.printStackTrace(); } }
From source file:digilib.pdf.PDFTitlePage.java
License:Open Source License
/** * generate iText-PDF-Contents for the title page * // ww w. ja v a 2 s . com * @return */ public Element getPageContents() { Paragraph content = new Paragraph(); content.setAlignment(Element.ALIGN_CENTER); // add vertical whitespace for (int i = 0; i < 8; i++) { content.add(Chunk.NEWLINE); } // add logo content.add(getLogo()); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); // add title Anchor title = new Anchor(new Paragraph(getTitle(), FontFactory.getFont(FontFactory.HELVETICA, 16))); String burl = job_info.getImageJobInformation().getAsString("base.url"); title.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn")); content.add(title); content.add(Chunk.NEWLINE); // add author if (getDate() != " ") content.add(new Paragraph(getAuthor() + " (" + getDate() + ")", FontFactory.getFont(FontFactory.HELVETICA, 14))); else content.add(new Paragraph(getAuthor(), FontFactory.getFont(FontFactory.HELVETICA, 14))); content.add(Chunk.NEWLINE); // add page numbers content.add(new Paragraph(getPages(), FontFactory.getFont(FontFactory.HELVETICA, 12))); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); content.add(Chunk.NEWLINE); // add digilib version content.add(new Paragraph(getDigilibVersion(), FontFactory.getFont(FontFactory.HELVETICA, 10))); for (int i = 0; i < 8; i++) { content.add(Chunk.NEWLINE); } Anchor address = new Anchor( new Paragraph(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn"), FontFactory.getFont(FontFactory.COURIER, 9))); address.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn")); content.add(address); return content; }
From source file:frames.main.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { try {/*from www . j a v a 2 s .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 ww w. j a v a 2s.c o m*/ //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 . jav a 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:modelo.crearPdf.java
public String pdf(int tiquet, int idOrden, String codOrden) { try {/*from www. j ava2 s .c o m*/ String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + tiquet + "'"; rs = Consultar(sql); int id = 0; int numTiquet = 0; String ob = ""; tiquet verTiquet = new tiquet(); colores verColor = new colores(); String colorUno = ""; String colorDos = ""; System.out.print("id de la orden en el tiquet:" + idOrden); ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; String verificacion = ""; //rs.last(); int cuantos = rs.getRow(); //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet); //Creamos el CHUNK definiendo su tipo de letra, tamao Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("Tiquet #", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("" + tiquet, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("Ref", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Par = new Chunk("Pares", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValPar = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq = new Chunk("Fecha", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("Orden", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cor = new Chunk("CORTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Guar = new Chunk("GUARNICION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMPLANTILLADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); //Fecha actual en formato completo: //Tue Sep 23 01:18:48 CEST 2014 Date fechaActual = new Date(); //Formateando la fecha: DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss"); DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd"); DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy"); // System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual)); String fe = Fecha.format(fechaActual); //Directorio destino para las descargas File folder = new File("c:\\seiya\\tiquets"); //Crea el directorio de destino en caso de que no exista folder.mkdirs(); int numeroAleatorio = (int) (Math.random() * 2500 + 1); //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion String dir = "C:\\seiya\\tiquets\\Tiquet_" + tiquet + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(300f, 792f); //ancho y alto //Creacion del documento con un tamao y unos margenes predeterminados Document document = new Document(pageSize, 1, 1, 1, 1); // Obtener la instancia del PdfWriter PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); //Opens the document. //You have to open the document before you can begin to add content to the body of the document. document.open(); //************************************************************** //Ejemplos de TABLE titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK)); document.add(titulo); //Aadir tabla 5 columnas PdfPTable table = new PdfPTable(15); //Aadir CABECERA PdfPCell cell = new PdfPCell(); cell.setColspan(15); table.addCell(cell); Image image = Image.getInstance("logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(7); table.addCell(cell); /* cell = new PdfPCell(new Phrase("imagen:")); cell.setColspan(4); cell.setRowspan(7); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); /*table.addCell(createImageCell(IMG1));*/ cell = new PdfPCell(new Phrase(direccion)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2); table.addCell(cell); while (rs.next()) { c1 = rs.getInt(1); c2 = rs.getInt(2); c3 = rs.getInt(3); c4 = rs.getInt(4); c5 = rs.getInt(5); observacion = rs.getString(6); verificacion = rs.getString(7); c8 = rs.getInt(8); c9 = rs.getInt(9); c10 = rs.getInt(10); c11 = rs.getInt(11); c12 = rs.getInt(12); c13 = rs.getInt(13); c14 = rs.getInt(14); c15 = rs.getInt(15); c16 = rs.getInt(16); c17 = rs.getInt(17); c18 = rs.getInt(18); c19 = rs.getInt(19); c20 = rs.getInt(20); c21 = rs.getInt(21); c22 = rs.getInt(22); c23 = rs.getInt(23); c24 = rs.getInt(24); c25 = rs.getInt(25); c26 = rs.getInt(26); c27 = rs.getInt(27); c28 = rs.getInt(28); c29 = rs.getInt(29); c30 = rs.getInt(30); c31 = rs.getInt(31); c32 = rs.getInt(32); c33 = rs.getInt(33); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); if (c3 != 0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) c05 = String.valueOf(c5); if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); if (c31 != 0) c031 = String.valueOf(c31); if (c32 != 0) c032 = String.valueOf(c32); if (c33 != 0) c033 = String.valueOf(c33); colorUno = verColor.consultarNombreColorUno(c4); colorDos = verColor.consultarNombreColorDos(c5); ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ob, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); System.out.print("Color Uno: " + colorUno); cell = new PdfPCell(new Phrase(Tiq)); cell.setColspan(3); cell.setRowspan(2); cell.setVerticalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setColspan(6); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c8)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2);//para eliminar espacio cabecera reemplazo el 2 por 3 table.addCell(cell); cell = new PdfPCell(new Phrase(Par)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c9)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(FechaTiq));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(fe));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("" + codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cor)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Guar)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(Mon)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(Emp)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(ValObserv)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell("" + c010); table.addCell("" + c011); table.addCell("" + c012); table.addCell("" + c013); table.addCell("" + c014); table.addCell("" + c015); table.addCell("" + c016); table.addCell("" + c017); table.addCell("" + c018); table.addCell("" + c019); table.addCell("" + c020); table.addCell("" + c021); table.addCell("" + c022); table.addCell("" + c023); table.addCell("" + c024); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); table.addCell(new Phrase(num44)); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell("" + c025); table.addCell("" + c026); table.addCell("" + c027); table.addCell("" + c028); table.addCell("" + c029); table.addCell("" + c030); table.addCell("" + c031); table.addCell("" + c032); table.addCell("" + c033); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.addCell(""); table.setWidthPercentage(100f); table.setHorizontalAlignment(Element.ALIGN_RIGHT); document.add(table); // String cadena=""; Chunk cadena = null; for (int i = 1; i <= 4; i++) { //Chunk chunkSeparador = new Chunk(SEPARADOR); // document.add(chunkSeparador); // document.add(Chunk.NEWLINE); PdfPTable tabla = new PdfPTable(15); if (i == 1) cadena = Emp; if (i == 2) cadena = Mon; if (i == 3) { cadena = Guar; } if (i == 4) cadena = Cor; cell = new PdfPCell( new Phrase("-----------------------------------------------------------------")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Encabezado)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(cadena)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Par)); cell.setHorizontalAlignment(Font.BOLD); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c9)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c8)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); tabla.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); tabla.addCell(cell); tabla.addCell(new Phrase(num21)); tabla.addCell(new Phrase(num22)); tabla.addCell(new Phrase(num23)); tabla.addCell(new Phrase(num24)); tabla.addCell(new Phrase(num25)); tabla.addCell(new Phrase(num26)); tabla.addCell(new Phrase(num27)); tabla.addCell(new Phrase(num28)); tabla.addCell(new Phrase(num29)); tabla.addCell(new Phrase(num30)); tabla.addCell(new Phrase(num31)); tabla.addCell(new Phrase(num32)); tabla.addCell(new Phrase(num33)); tabla.addCell(new Phrase(num34)); tabla.addCell(new Phrase(num35)); tabla.addCell("" + c010); tabla.addCell("" + c011); tabla.addCell("" + c012); tabla.addCell("" + c013); tabla.addCell("" + c014); tabla.addCell("" + c015); tabla.addCell("" + c016); tabla.addCell("" + c017); tabla.addCell("" + c018); tabla.addCell("" + c019); tabla.addCell("" + c020); tabla.addCell("" + c021); tabla.addCell("" + c022); tabla.addCell("" + c023); tabla.addCell("" + c024); tabla.addCell(new Phrase(num36)); tabla.addCell(new Phrase(num37)); tabla.addCell(new Phrase(num38)); tabla.addCell(new Phrase(num39)); tabla.addCell(new Phrase(num40)); tabla.addCell(new Phrase(num41)); tabla.addCell(new Phrase(num42)); tabla.addCell(new Phrase(num43)); tabla.addCell(new Phrase(num44)); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell("" + c025); tabla.addCell("" + c026); tabla.addCell("" + c027); tabla.addCell("" + c028); tabla.addCell("" + c029); tabla.addCell("" + c030); tabla.addCell("" + c031); tabla.addCell("" + c032); tabla.addCell("" + c033); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.addCell(""); tabla.setWidthPercentage(100f); tabla.setHorizontalAlignment(Element.ALIGN_RIGHT); document.add(tabla); } //FIN Ejemplos de TABLE } document.close(); return "exito"; } catch (Exception ex) { System.out.println(ex.getMessage()); return "Error al Generar el PDF"; } }
From source file:modelo.impOrdenCarta.java
public boolean impOrden(int idOrden, String codOrden, int numRegTiq) { try {//from w ww. ja v a2s . c om int id = 0; int numTiquet = 0; String ob = ""; colores verColor = new colores(); String colorUno = ""; String colorDos = ""; ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; int CanTotal = 0; int idCliente = 0; String ciu = ""; String fecped = ""; String fecent = ""; for (orden ord : new orden().CargarDatosOrden(codOrden)) { idCliente = ord.getCliente(); ciu = ord.getCiudad(); fecped = ord.getPedido(); fecent = ord.getEntrega(); } String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente); Chunk idClient = new Chunk(nomCliente, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("TK", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("REF", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Cliente = new Chunk("CLIENTE", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecEnt = new Chunk("FECHA ENTREGA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecEnt = new Chunk(fecent, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecPed = new Chunk("FECHA PEDIDO", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecPed = new Chunk(fecped, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("ORDEN", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ciudad = new Chunk("CIUDAD", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCiudad = new Chunk(ciu, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cant = new Chunk("CANT.", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMPLANTILLADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); File folder = new File("c:\\seiya\\ordenes"); folder.mkdirs(); String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(792f, 612f); Document document = new Document(pageSize, 1, 1, 1, 1); PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); document.open(); PdfPTable table = new PdfPTable(40); PdfPCell cell = new PdfPCell(); Image image = Image.getInstance("logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(7); cell.setRowspan(7); table.addCell(cell); cell = new PdfPCell(new Phrase(direccion)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(33); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cliente)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(idClient)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(9); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ciudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCiudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cant)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); table.addCell(cell); ArrayList<String> resultat; resultat = nuevoTiquet.consultarTiquetporOrden(idOrden); Iterator<String> tiquetIterator = resultat.iterator(); while (tiquetIterator.hasNext()) { String valorTiquet = tiquetIterator.next(); System.out.print(valorTiquet + " ------ "); int tiq = Integer.parseInt(valorTiquet); ArrayList<tiquet> listaDatosTiquet; listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList for (tiquet ord : new tiquet().conten(idOrden, tiq)) { System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden)); c1 = ord.getTiquet(); c2 = ord.getIdorden(); observacion = ord.getObservacion(); c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden); c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden); c8 = ord.getN21(); c9 = ord.getN22(); c10 = ord.getN23(); c11 = ord.getN24(); c12 = ord.getN25(); c13 = ord.getN26(); c14 = ord.getN27(); c15 = ord.getN28(); c16 = ord.getN29(); c17 = ord.getN30(); c18 = ord.getN31(); c19 = ord.getN32(); c20 = ord.getN33(); c21 = ord.getN34(); c22 = ord.getN35(); c23 = ord.getN36(); c24 = ord.getN37(); c25 = ord.getN38(); c26 = ord.getN39(); c27 = ord.getN40(); c28 = ord.getN41(); c29 = ord.getN42(); c30 = ord.getN43(); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); // if(c3!=0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) { c05 = String.valueOf(c5); CanTotal += c5; } if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); cell = new PdfPCell(new Phrase(String.valueOf(tiq))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c04)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c05)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c08)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c09)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c010)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c011)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c012)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c013)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c014)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c015)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c016)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c017)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c018)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c019)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c020)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c021)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c022)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c023)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c024)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c025)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c026)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c027)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c028)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c029)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c030)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno()); colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos()); // ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ord.getObservacion(), FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValObserv)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); table.addCell(cell); } } cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(CanTotal))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(25); cell.setRowspan(1); table.addCell(cell); table.setWidthPercentage(95f); table.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(table); document.close(); return true; } catch (Exception x) { return false; } }
From source file:modelo.impOrdenLegal.java
public boolean impOrden(int idOrden, String codOrden, int numRegTiq) { try {//w w w . ja va 2 s . c o m int id = 0; int numTiquet = 0; String ob = ""; colores verColor = new colores(); String colorUno = ""; String colorDos = ""; ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; int CanTotal = 0; int idCliente = 0; String ciu = ""; String fecped = ""; String fecent = ""; for (orden ord : new orden().CargarDatosOrden(codOrden)) { idCliente = ord.getCliente(); ciu = ord.getCiudad(); fecped = ord.getPedido(); fecent = ord.getEntrega(); } String nomCliente = nuevaOrden.ConsultarNombreCliente(idCliente); Chunk idClient = new Chunk(nomCliente, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("TK", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("REF", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 12, Font.NORMAL, BaseColor.BLACK)); Chunk Cliente = new Chunk("CLIENTE", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecEnt = new Chunk("FECHA ENTREGA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecEnt = new Chunk(fecent, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecPed = new Chunk("FECHA PEDIDO", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecPed = new Chunk(fecped, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("ORDEN", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ciudad = new Chunk("CIUDAD", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCiudad = new Chunk(ciu, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cant = new Chunk("CANT.", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cor = new Chunk("CORT", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Guar = new Chunk("GUAR", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONT", FontFactory.getFont(FontFactory.COURIER_BOLD, 9, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMP", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); File folder = new File("c:\\seiya\\ordenes"); folder.mkdirs(); String dir = "C:\\seiya\\ordenes\\Orden_Legal_" + codOrden + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(1008f, 612f); Document document = new Document(pageSize, 1, 1, 1, 1); PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); document.open(); PdfPTable table = new PdfPTable(50); PdfPCell cell = new PdfPCell(); Image image = Image.getInstance("logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(7); cell.setRowspan(7); table.addCell(cell); cell = new PdfPCell(new Phrase(direccion)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Tel)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(Correo)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(43); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cliente)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(idClient)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(12); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ciudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCiudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValFecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("ETAPA DEL PROCESO")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(8); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cant)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(8); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cor)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Guar)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Mon)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Emp)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); ArrayList<String> resultat; resultat = nuevoTiquet.consultarTiquetporOrden(idOrden); Iterator<String> tiquetIterator = resultat.iterator(); while (tiquetIterator.hasNext()) { String valorTiquet = tiquetIterator.next(); System.out.print(valorTiquet + " ------ "); int tiq = Integer.parseInt(valorTiquet); ArrayList<tiquet> listaDatosTiquet; listaDatosTiquet = nuevoTiquet.conten(idOrden, tiq);//La consulta tiene que retornar un ArrayList for (tiquet ord : new tiquet().conten(idOrden, tiq)) { System.out.print("Referencia: " + nuevoTiquet.ConsultarReferencia(tiq, idOrden)); c1 = ord.getTiquet(); c2 = ord.getIdorden(); observacion = ord.getObservacion(); c4 = nuevoTiquet.ConsultarReferencia(tiq, idOrden); c5 = nuevoTiquet.ConsultarCantidad(tiq, idOrden); c8 = ord.getN21(); c9 = ord.getN22(); c10 = ord.getN23(); c11 = ord.getN24(); c12 = ord.getN25(); c13 = ord.getN26(); c14 = ord.getN27(); c15 = ord.getN28(); c16 = ord.getN29(); c17 = ord.getN30(); c18 = ord.getN31(); c19 = ord.getN32(); c20 = ord.getN33(); c21 = ord.getN34(); c22 = ord.getN35(); c23 = ord.getN36(); c24 = ord.getN37(); c25 = ord.getN38(); c26 = ord.getN39(); c27 = ord.getN40(); c28 = ord.getN41(); c29 = ord.getN42(); c30 = ord.getN43(); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); // if(c3!=0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) { c05 = String.valueOf(c5); CanTotal += c5; } if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); cell = new PdfPCell(new Phrase(String.valueOf(tiq))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c04)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c05)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c08)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c09)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c010)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c011)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c012)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c013)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c014)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c015)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c016)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c017)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c018)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c019)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c020)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c021)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c022)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c023)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c024)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c025)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c026)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c027)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c028)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c029)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(c030)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(1); cell.setRowspan(1); table.addCell(cell); colorUno = verColor.consultarNombreColorUno(ord.getIdcoloruno()); colorDos = verColor.consultarNombreColorDos(ord.getIdcolordos()); // ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ord.getObservacion(), FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)); cell = new PdfPCell(new Phrase(ValCol1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValCol2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(ValObserv)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(8); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); } } cell = new PdfPCell(new Phrase("Cantidad Total de Pares Producidos ")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(CanTotal))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(35); cell.setRowspan(1); table.addCell(cell); table.setWidthPercentage(95f); table.setHorizontalAlignment(Element.ALIGN_CENTER); document.add(table); document.close(); return true; } catch (Exception x) { return false; } }
From source file:modelo.pdfOrden.java
public String pdf(int tiquet, int idOrden, String codOrden, int numRegTiq) { try {/* www . j a v a 2s .c o m*/ int id = 0; int numTiquet = 0; String ob = ""; tiquet verTiquet = new tiquet(); colores verColor = new colores(); String colorUno = ""; String colorDos = ""; System.out.print("id de la orden en el tiquet:" + idOrden); ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0, c33 = 0; String observacion = ""; String verificacion = ""; int idCliente = 0; String ciu = ""; String fecped = ""; String fecent = ""; for (orden ord : new orden().CargarDatosOrden(codOrden)) { idCliente = ord.getCliente(); ciu = ord.getCiudad(); fecped = ord.getPedido(); fecent = ord.getEntrega(); } //rs.last(); // int cuantos = rs.getRow(); //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet); //Creamos el CHUNK definiendo su tipo de letra, tamao Chunk idClient = new Chunk("" + idCliente, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk direccion = new Chunk("Calle 12 # 6-68 Nia Ceci", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tiq = new Chunk("TK", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValTiq = new Chunk("" + tiquet, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Tel = new Chunk("Tel: 5783364", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ref = new Chunk("REF", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValRef = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Correo = new Chunk("calzadoseiya@gmail.com", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Cliente = new Chunk("CLIENTE", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecEnt = new Chunk("FECHA ENTREGA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecEnt = new Chunk(fecent, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FecPed = new Chunk("FECHA PEDIDO", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValFecPed = new Chunk(fecped, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk FechaTiq2 = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Orden = new Chunk("ORDEN", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValOrd = new Chunk("", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Ciudad = new Chunk("CIUDAD", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCiudad = new Chunk(ciu, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Cant = new Chunk("CANT.", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Mon = new Chunk("MONTADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Emp = new Chunk("EMPLANTILLADA", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk OBSER = new Chunk("OBSERVACION", FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk Col1 = new Chunk("Color 1", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Col2 = new Chunk("Color 2", FontFactory.getFont(FontFactory.COURIER_BOLD, 8, Font.NORMAL, BaseColor.BLACK)); Chunk Encabezado = new Chunk("SEIYA", FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.NORMAL, BaseColor.BLACK)); Chunk num21 = new Chunk("21", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num22 = new Chunk("22", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num23 = new Chunk("23", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num24 = new Chunk("24", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num25 = new Chunk("25", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num26 = new Chunk("26", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num27 = new Chunk("27", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num28 = new Chunk("28", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num29 = new Chunk("29", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num30 = new Chunk("30", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num31 = new Chunk("31", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num32 = new Chunk("32", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num33 = new Chunk("33", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num34 = new Chunk("34", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num35 = new Chunk("35", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num36 = new Chunk("36", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num37 = new Chunk("37", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num38 = new Chunk("38", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num39 = new Chunk("39", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num40 = new Chunk("40", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num41 = new Chunk("41", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num42 = new Chunk("42", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num43 = new Chunk("43", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); Chunk num44 = new Chunk("44", FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)); //Fecha actual en formato completo: //Tue Sep 23 01:18:48 CEST 2014 Date fechaActual = new Date(); //Formateando la fecha: DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss"); DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd"); DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy"); // System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual)); String fe = Fecha.format(fechaActual); //Directorio destino para las descargas File folder = new File("c:\\seiya\\ordenes"); //Crea el directorio de destino en caso de que no exista folder.mkdirs(); int numeroAleatorio = (int) (Math.random() * 2500 + 1); //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion String dir = "C:\\seiya\\ordenes\\Orden_" + codOrden + ".pdf"; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); Rectangle pageSize = new Rectangle(792f, 612f); //ancho y alto ->tamao carta //Creacion del documento con un tamao y unos margenes predeterminados Document document = new Document(pageSize, 1, 1, 1, 1); // Obtener la instancia del PdfWriter PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); //Opens the document. //You have to open the document before you can begin to add content to the body of the document. document.open(); //************************************************************** //Ejemplos de TABLE titulo = new Chunk("", FontFactory.getFont(FontFactory.COURIER, 20, Font.UNDERLINE, BaseColor.BLACK)); document.add(titulo); //Aadir tabla 5 columnas PdfPTable table = new PdfPTable(40); //Aadir CABECERA PdfPCell cell = new PdfPCell(); /*table.addCell(createImageCell(IMG1));*/ cell = new PdfPCell(new Phrase(Tiq)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Orden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cliente)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(9); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ciudad)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecPed)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(FecEnt)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Ref)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Cant)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); table.addCell(new Phrase(num21)); table.addCell(new Phrase(num22)); table.addCell(new Phrase(num23)); table.addCell(new Phrase(num24)); table.addCell(new Phrase(num25)); table.addCell(new Phrase(num26)); table.addCell(new Phrase(num27)); table.addCell(new Phrase(num28)); table.addCell(new Phrase(num29)); table.addCell(new Phrase(num30)); table.addCell(new Phrase(num31)); table.addCell(new Phrase(num32)); table.addCell(new Phrase(num33)); table.addCell(new Phrase(num34)); table.addCell(new Phrase(num35)); table.addCell(new Phrase(num36)); table.addCell(new Phrase(num37)); table.addCell(new Phrase(num38)); table.addCell(new Phrase(num39)); table.addCell(new Phrase(num40)); table.addCell(new Phrase(num41)); table.addCell(new Phrase(num42)); table.addCell(new Phrase(num43)); cell = new PdfPCell(new Phrase(Col1)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(Col2)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase(OBSER)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); table.addCell(cell); /* ArrayList<String> resul; resul = nuevoTiquet.CargarComboTiquet(id);//La consulta tiene que retornar un ArrayList Iterator<String> tiqIterator = resul.iterator(); while(tiqIterator.hasNext()){ String valorTiq = tiqIterator.next(); //System.out.print(valorTiquet+" / "); // this.impOrd.imp(valorTiq, idOrden, idCadOrden, numRegTiq ); } */ ArrayList<String> resultat; resultat = nuevoTiquet.consultarTiquetporOrden(idOrden); Iterator<String> tiquetIterator = resultat.iterator(); while (tiquetIterator.hasNext()) { String valorTiquet = tiquetIterator.next(); System.out.print(valorTiquet + " ------ "); String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + valorTiquet + "'"; rs = Consultar(sql); while (rs.next()) { c1 = rs.getInt(1); c2 = rs.getInt(2); c3 = rs.getInt(3); c4 = rs.getInt(4); c5 = rs.getInt(5); observacion = rs.getString(6); verificacion = rs.getString(7); c8 = rs.getInt(8); c9 = rs.getInt(9); c10 = rs.getInt(10); c11 = rs.getInt(11); c12 = rs.getInt(12); c13 = rs.getInt(13); c14 = rs.getInt(14); c15 = rs.getInt(15); c16 = rs.getInt(16); c17 = rs.getInt(17); c18 = rs.getInt(18); c19 = rs.getInt(19); c20 = rs.getInt(20); c21 = rs.getInt(21); c22 = rs.getInt(22); c23 = rs.getInt(23); c24 = rs.getInt(24); c25 = rs.getInt(25); c26 = rs.getInt(26); c27 = rs.getInt(27); c28 = rs.getInt(28); c29 = rs.getInt(29); c30 = rs.getInt(30); c31 = rs.getInt(31); c32 = rs.getInt(32); c33 = rs.getInt(33); String c01 = " ", c02 = " ", c03 = " ", c04 = " ", c05 = " ", c06 = " ", c07 = " ", c08 = " ", c09 = " ", c010 = " ", c011 = " ", c012 = " "; String c013 = " ", c014 = " ", c015 = " ", c016 = " ", c017 = " ", c018 = " ", c019 = " ", c020 = " ", c021 = " ", c022 = " ", c023 = " ", c024 = " "; String c025 = " ", c026 = " ", c027 = " ", c028 = " ", c029 = " ", c030 = " ", c031 = " ", c032 = " ", c033 = " ", c034 = " "; if (c1 != 0) c01 = String.valueOf(c1); if (c2 != 0) c02 = String.valueOf(c2); if (c3 != 0) c03 = String.valueOf(c3); if (c4 != 0) c04 = String.valueOf(c4); if (c5 != 0) c05 = String.valueOf(c5); if (c8 != 0) c08 = String.valueOf(c8); if (c9 != 0) c09 = String.valueOf(c9); if (c10 != 0) c010 = String.valueOf(c10); if (c11 != 0) c011 = String.valueOf(c11); if (c12 != 0) c012 = String.valueOf(c12); if (c13 != 0) c013 = String.valueOf(c13); if (c14 != 0) c014 = String.valueOf(c14); if (c15 != 0) c015 = String.valueOf(c15); if (c16 != 0) c016 = String.valueOf(c16); if (c17 != 0) c017 = String.valueOf(c17); if (c18 != 0) c018 = String.valueOf(c18); if (c19 != 0) c019 = String.valueOf(c19); if (c20 != 0) c020 = String.valueOf(c20); if (c21 != 0) c021 = String.valueOf(c21); if (c22 != 0) c022 = String.valueOf(c22); if (c23 != 0) c023 = String.valueOf(c23); if (c24 != 0) c024 = String.valueOf(c24); if (c25 != 0) c025 = String.valueOf(c25); if (c26 != 0) c026 = String.valueOf(c26); if (c27 != 0) c027 = String.valueOf(c27); if (c28 != 0) c028 = String.valueOf(c28); if (c29 != 0) c029 = String.valueOf(c29); if (c30 != 0) c030 = String.valueOf(c30); if (c31 != 0) c031 = String.valueOf(c31); if (c32 != 0) c032 = String.valueOf(c32); if (c33 != 0) c033 = String.valueOf(c33); colorUno = verColor.consultarNombreColorUno(c4); colorDos = verColor.consultarNombreColorDos(c5); // ob = verTiquet.ConsultaObservacion(tiquet); Chunk ValCol1 = new Chunk(colorUno, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValCol2 = new Chunk(colorDos, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); Chunk ValObserv = new Chunk(ob, FontFactory.getFont(FontFactory.COURIER_BOLD, 10, Font.NORMAL, BaseColor.BLACK)); System.out.print("Color Uno: " + colorUno); table.addCell(new Phrase(ValTiq)); table.addCell("2"); table.addCell("3"); table.addCell("4"); table.addCell("5"); table.addCell("6"); table.addCell("7"); table.addCell("8"); table.addCell("9"); table.addCell("10"); table.addCell("11"); table.addCell("12"); table.addCell("13"); table.addCell("14"); table.addCell("15"); table.addCell("16"); table.addCell("17"); table.addCell("18"); table.addCell("18"); table.addCell("20"); table.addCell("21"); table.addCell("22"); table.addCell("23"); table.addCell("24"); table.addCell("25"); table.addCell("26"); table.addCell("27"); table.addCell("28"); table.addCell("29"); table.addCell("30"); table.addCell("31"); table.addCell("32"); table.addCell("33"); table.addCell("34"); table.addCell("35"); table.addCell("36"); table.addCell("37"); table.addCell("38"); table.addCell("39"); table.addCell("40"); table.setWidthPercentage(100f); table.setHorizontalAlignment(Element.ALIGN_RIGHT); document.add(table); } } document.close(); return "exito"; } catch (Exception ex) { System.out.println(ex.getMessage()); return "Error al Generar el PDF"; } }