List of usage examples for com.lowagie.text.pdf PdfPTable getDefaultCell
public PdfPCell getDefaultCell()
PdfPCell
that will be used as reference for all the addCell
methods except addCell(PdfPCell)
. From source file:storemanagment.Printing.java
public final void TransactionGiven(String transactionReceiptNo, String officer, ArrayList<CartPojo> items) { Calendar c = Calendar.getInstance(); Date today = c.getTime();//from w w w .j av a2s. c om java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream( new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, transactionReceiptNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell("Transaction Receipt"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(3); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((CartPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((CartPojo) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((CartPojo) items.get(a)).getTransaction_quantity_in(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void TransactionReceived(String transactionReceiptNo, String officer, ArrayList<ReceivedCart> items, String total_cash, String[] otherDetails) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/* ww w .j av a 2 s. com*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream( new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, transactionReceiptNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(createTextCellNb("")); RecieptTilte.addCell("GOODS RECEIVED NOTE"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(createTextCellNb("")); PdfPTable RecieptFrom = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptFrom.setTotalWidth(575); RecieptFrom.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptFrom.setWidths(new int[] { 1, 1, 1 }); // RecieptFrom.setSpacingBefore(8); // RecieptFrom.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptFrom.getDefaultCell().setBorderWidthLeft(0); RecieptFrom.getDefaultCell().setBorderWidthRight(0); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("Received From : ")); RecieptFrom.addCell(createTextCellNb(otherDetails[0])); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("Address :")); RecieptFrom.addCell(createTextCellNb(otherDetails[1])); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); // otherDetails[0]=from; // otherDetails[1]=fromAddress; // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; PdfPTable RecieptitemsTitles = new PdfPTable(5); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Description")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Purchase Order No")); RecieptitemsTitles.addCell(creatTextCellTitles("Rate(Kshs)")); RecieptitemsTitles.addCell(creatTextCellTitles("Value(Kshs)")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((ReceivedCart) items.get(a)).getItem_name(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((ReceivedCart) items.get(a)).getTransaction_purchase_order_no(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_item_cash(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_cash(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } PdfPTable RecieptTotals = new PdfPTable(4); // // tbl.setWidthPercentage(100); // RecieptTotals.setTotalWidth(575); RecieptTotals.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTotals.setWidths(new int[] { 1, 1, 1, 1 }); RecieptTotals.setSpacingBefore(8); RecieptTotals.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTotals.getDefaultCell().setBorderWidthLeft(0); RecieptTotals.getDefaultCell().setBorderWidthRight(0); // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("Received By : ")); RecieptTotals.addCell(createTextCellNb(otherDetails[2])); RecieptTotals.addCell(createTextCellNb("Delivered By :")); RecieptTotals.addCell(createTextCellNb(otherDetails[5])); RecieptTotals.addCell(createTextCellNb("Designation : ")); RecieptTotals.addCell(createTextCellNb(otherDetails[3])); RecieptTotals.addCell(createTextCellNb("Total :")); RecieptTotals.addCell(createTextCellNb(total_cash)); RecieptTotals.addCell(createTextCellNb("Department :")); RecieptTotals.addCell(createTextCellNb(otherDetails[4])); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); PdfPTable RecieptEnds = new PdfPTable(3); RecieptEnds.setTotalWidth(575); RecieptEnds.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptEnds.setWidths(new int[] { 1, 1, 1 }); RecieptEnds.setSpacingBefore(8); RecieptEnds.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptEnds.getDefaultCell().setBorderWidthLeft(0); RecieptEnds.getDefaultCell().setBorderWidthRight(0); // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("Store Ledger No : ")); RecieptEnds.addCell(createTextCellNb("Invoice No : ")); RecieptEnds.addCell(createTextCellNb("Suppliers Delivery No :")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb(transactionReceiptNo)); RecieptEnds.addCell(createTextCellNb(otherDetails[6])); RecieptEnds.addCell(createTextCellNb("-----------------")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptFrom); pdfp.add(RecieptitemsTitles); pdfp.add(RecieptTotals); pdfp.add(RecieptEnds); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void Inventory(String store, String officer, ArrayList<ItemsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*ww w. j a va 2 s.c o m*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " INVENTORY"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(3); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity_in(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void StoreTaking(String store, String officer, ArrayList<ItemsPojo> items) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*from w w w. j av a2s . c o m*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); FooterOnly event = new FooterOnly(officer, "", DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Stock Taking Guide"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(5); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); RecieptitemsTitles.addCell(creatTextCellTitles("Ph")); RecieptitemsTitles.addCell(creatTextCellTitles("Var")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity_in(), a)); RecieptitemsTitles.addCell(createTextCellcolor("", 1)); RecieptitemsTitles.addCell(createTextCellcolor("", 1)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void Transactions(String store, String officer, ArrayList<TransactionsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();//from w w w . ja v a 2 s . c om java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Transactions"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(9); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 1, 1, 2, 1, 1, 1, 1, 1, 2 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Type")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit Rate")); RecieptitemsTitles.addCell(creatTextCellTitles("Total Cash")); RecieptitemsTitles.addCell(creatTextCellTitles("From")); RecieptitemsTitles.addCell(creatTextCellTitles("To")); RecieptitemsTitles.addCell(creatTextCellTitles("R.No")); RecieptitemsTitles.addCell(creatTextCellTitles("Date")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_quantity() + " " + ((TransactionsPojo) items.get(a)).getTransaction_quantity_in(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_type(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_item_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_from(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_to(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((TransactionsPojo) items.get(a)).getTransaction_receipt_no_out(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_time_string(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void StockTake(String store, String officer, ArrayList<TransactionsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*from w ww . j av a2 s . com*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "st" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Transactions"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(8); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 1, 1, 2, 1, 1, 1, 1, 2 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Type")); RecieptitemsTitles.addCell(creatTextCellTitles("Cash")); RecieptitemsTitles.addCell(creatTextCellTitles("From")); RecieptitemsTitles.addCell(creatTextCellTitles("To")); RecieptitemsTitles.addCell(creatTextCellTitles("R.No")); RecieptitemsTitles.addCell(creatTextCellTitles("Date")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_type(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_from(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_to(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((TransactionsPojo) items.get(a)).getTransaction_receipt_no_out(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_time_string(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createSpeakerNotes4PerPage(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612/*from w ww. jav a 2 s . c om*/ //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); PdfPTable table; PdfPCell cell; int entryCount = 0; int entryOnPage = 0; int currentIndex = VUE.getActivePathway().getIndex(); VUE.getActivePathway().setIndex(-1); for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) { final LWSlide slide = entry.produceSlide(); final LWComponent toDraw = (slide == null ? entry.node : slide); final String notes = entry.getNotes(); entryCount++; table = new PdfPTable(new float[] { 1, 1 }); table.getDefaultCell().setBorder(0); //table.getDefaultCell().setPaddingBottom(50.0f); table.setSpacingAfter(20.0f); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); Phrase phrase = new Phrase(notes); Font f = phrase.getFont(); f.setSize(8.0f); p.setFont(f); cell = new PdfPCell(phrase); cell.setBorder(0); PdfPCell i2 = new PdfPCell(); i2.setFixedHeight(172); i2.setBorder(0); //Render the table then throw the images on PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY); Point2D.Float offset = new Point2D.Float(); // center vertically only if landscape mode //if (format.getOrientation() == PageFormat.LANDSCAPE) //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit) Rectangle2D bounds = null; //if (!entry.isMapView()) bounds = slide.getBounds(); //else //bounds = entry.getFocal().getBounds(); Dimension page = null; page = new Dimension(SlideSizeX, 172); //PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80); double scale = ZoomTool.computeZoomFit(page, 5, bounds, offset, true); PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(), false, 60.0f); DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle entry.isMapView() ? entry.getFocal() : slide, false); // todo: absolute links shouldn't be spec'd here dc.setClipOptimized(false); dc.setPrintQuality(); /*if (!entry.isMapView()) slide.drawZero(dc); else { entry.getFocal().draw(dc); }*/ toDraw.drawFit(dc, 0); g2d.dispose(); //document.add(Image.getInstance(tp)); // int position = cell. // drawSequenceNumber(writer,36,position+203,entryCount); // cb.addTemplate(tp,56, position); Image img = Image.getInstance(tp); table.addCell(img); table.addCell(cell); p.add(table); document.add(p); } VUE.getActivePathway().setIndex(currentIndex); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createNodeNotes4PerPage(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612/*from www . jav a 2 s . com*/ //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); PdfPTable table; PdfPCell cell; int entryCount = 0; int entryOnPage = 0; Iterator i = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); while (i.hasNext()) { LWComponent component = (LWComponent) i.next(); if (component instanceof LWNode) { final LWNode node = (LWNode) component; final String notes = node.getNotes(); entryCount++; table = new PdfPTable(new float[] { 1, 1 }); table.getDefaultCell().setBorder(0); table.setSpacingAfter(20.0f); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); Phrase phrase = new Phrase(notes); Font f = phrase.getFont(); f.setSize(8.0f); p.setFont(f); cell = new PdfPCell(phrase); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setBorder(0); PdfPCell i2 = new PdfPCell(); i2.setFixedHeight(172); i2.setBorder(0); //Render the table then throw the images on PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY); Point2D.Float offset = new Point2D.Float(); //center vertically only if landscape mode //if (format.getOrientation() == PageFormat.LANDSCAPE) //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit) Rectangle2D bounds = null; bounds = node.getBounds(); Dimension page = null; page = new Dimension(SlideSizeX, 172); // PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80); double scale = ZoomTool.computeZoomFit(page, 15, bounds, offset, true); PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(), false, 60.0f); DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle node, false); // todo: absolute links shouldn't be spec'd here dc.setClipOptimized(false); dc.setPrintQuality(); node.drawFit(dc, 15); g2d.dispose(); Image img = Image.getInstance(tp); table.addCell(img); table.addCell(cell); p.add(table); document.add(p); } } } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:uk.ac.bbsrc.tgac.miso.core.data.decorator.itext.ITextProjectDecorator.java
License:Open Source License
public void buildReport() throws DocumentException { report = new Document(); PdfWriter writer = PdfWriter.getInstance(report, stream); report.open();/* w w w. ja v a 2 s . com*/ report.add(new Paragraph("Project Summary")); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(2.0f); // Make a bit thicker than 1.0 default cb.setGrayStroke(0.9f); // 1 = black, 0 = white float x = 72f; float y = 200f; cb.moveTo(x, y); cb.lineTo(x + 72f * 6, y); cb.stroke(); report.add(new Paragraph(project.getAlias())); report.add(new Paragraph(project.getDescription())); PdfPTable t = new PdfPTable(1); t.setHorizontalAlignment(Element.ALIGN_CENTER); t.setWidthPercentage(100f); // this would be the 100 from setHorizontalLine t.setSpacingAfter(5f); t.setSpacingBefore(0f); t.getDefaultCell().setUseVariableBorders(true); t.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); t.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); t.getDefaultCell().setBorder(Rectangle.BOTTOM); // This generates the line t.getDefaultCell().setBorderWidth(1f); // this would be the 1 from setHorizontalLine t.getDefaultCell().setPadding(0); t.addCell(""); report.add(t); x = 72f; y = 100f; cb.moveTo(x, y); cb.lineTo(x + 72f * 6, y); cb.stroke(); if (project.getSamples().size() > 0) { report.add(new Paragraph("Samples")); for (Sample sample : project.getSamples()) { Paragraph sPara = new Paragraph(sample.getAlias(), FontFactory.getFont("Helvetica", 12, Font.BOLD)); sPara.setIndentationLeft(20); report.add(sPara); report.add(new Paragraph(sample.getDescription())); } } report.close(); }
From source file:wagwaan.reports.ActiveSuppliersPdf.java
public void generatePdf() { try {/*from w ww . j a va 2s .com*/ java.io.File tempFile = java.io.File.createTempFile("REP" + label.getDateLable() + "_", ".pdf"); tempFile.deleteOnExit(); java.lang.Runtime rt = java.lang.Runtime.getRuntime(); java.lang.String debitTotal = null; java.lang.String creditTotal = null; com.lowagie.text.Document docPdf = new com.lowagie.text.Document(PageSize.A4.rotate()); try { try { com.lowagie.text.pdf.PdfWriter.getInstance(docPdf, new java.io.FileOutputStream(tempFile)); ReportUtil.addCenteredTitlePage(docPdf, connectDB); String date = null; try { java.sql.Statement st3 = connectDB.createStatement(); java.sql.Statement st4 = connectDB.createStatement(); java.sql.ResultSet rset4 = st4.executeQuery("SELECT date(now()) as Date"); while (rset4.next()) date = rset4.getObject(1).toString(); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } com.lowagie.text.HeaderFooter footer = new com.lowagie.text.HeaderFooter( new Phrase("Active Suppliers- Page: "), true);// FontFactory.getFont(com.lowagie.text.FontFactory.HELVETICA, 12, Font.BOLDITALIC,java.awt.Color.blue)); docPdf.setFooter(footer); docPdf.open(); ReportUtil.addCenteredTitlePage(docPdf, connectDB); try { com.lowagie.text.pdf.PdfPTable table = new com.lowagie.text.pdf.PdfPTable(10); int headerwidths[] = { 4, 6, 20, 11, 11, 10, 10, 10, 10, 9 }; table.setWidths(headerwidths); table.setWidthPercentage((100)); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.getDefaultCell().setColspan(5); Phrase phrase; java.text.DateFormat dateFormat = java.text.DateFormat .getDateInstance(java.text.DateFormat.MEDIUM); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase("Active Suppliers"); table.addCell(phrase); // table.getDefaultCell().setColspan(4); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); phrase = new Phrase("Printed On :" + date, pFontHeader); table.addCell(phrase); table.getDefaultCell().setColspan(1); table.getDefaultCell() .setBorder(PdfCell.TOP | PdfCell.BOTTOM | PdfCell.LEFT | PdfCell.RIGHT); phrase = new Phrase("#", pFontHeader); table.addCell(phrase); phrase = new Phrase("Suplier ID", pFontHeader); table.addCell(phrase); phrase = new Phrase("Supplier Names", pFontHeader); table.addCell(phrase); phrase = new Phrase("Address", pFontHeader); table.addCell(phrase); phrase = new Phrase("Phone No", pFontHeader); table.addCell(phrase); phrase = new Phrase("Email", pFontHeader); table.addCell(phrase); phrase = new Phrase("Bank Name", pFontHeader); table.addCell(phrase); phrase = new Phrase("Account No", pFontHeader); table.addCell(phrase); phrase = new Phrase("Branch Name", pFontHeader); table.addCell(phrase); phrase = new Phrase("Reg. Date", pFontHeader); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_RIGHT); table.getDefaultCell().setBackgroundColor(java.awt.Color.WHITE); try { /*Statement s=connectDB.createStatement(); ResultSet r=s.executeQuery("SELECT sum(ord.price*quantity_received) total FROM st_receiving_issuing REV, stock_orders ord, stock_items itm " + "where receiving_no='"+issue+"' and itm.item_code=ord.item_code and itm.item_code=rev.item_code");*/ java.sql.Statement st = connectDB.createStatement(); java.sql.ResultSet rset = st.executeQuery( "select supplier_id, supplier_names, address, phone_no, email_address, bank_name, account_no, " + "branch_name, date_registered from stock_suppliers where active=true order by 1, 2"); int count = 1; while (rset.next()) { table.getDefaultCell().setColspan(1); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER); table.getDefaultCell().setColspan(1); numberSeq += 1; phrase = new Phrase("" + count + " ", pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(1), "-"), pFontHeader1); table.addCell(phrase); phrase = new Phrase(dbObject.getDBObject(rset.getObject(2), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(3), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(4), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(5), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(6), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(7), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(8), "-"), pFontHeader1); table.addCell(phrase); table.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT); phrase = new Phrase(dbObject.getDBObject(rset.getObject(9), "-"), pFontHeader1); table.addCell(phrase); count++; } docPdf.add(table); } catch (java.sql.SQLException SqlExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), SqlExec.getMessage()); } } catch (com.lowagie.text.BadElementException BadElExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), BadElExec.getMessage()); } } catch (java.io.FileNotFoundException fnfExec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), fnfExec.getMessage()); } catch (SQLException ex) { Logger.getLogger(ActiveSuppliersPdf.class.getName()).log(Level.SEVERE, null, ex); } catch (BadElementException ex) { Logger.getLogger(ActiveSuppliersPdf.class.getName()).log(Level.SEVERE, null, ex); } } catch (com.lowagie.text.DocumentException lwDocexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), lwDocexec.getMessage()); } docPdf.close(); deskTop.open(tempFile); } catch (java.io.IOException IOexec) { javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), IOexec.getMessage()); } }