List of usage examples for com.lowagie.text.pdf PdfPTable setSpacingAfter
public void setSpacingAfter(float spacing)
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.jav 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();/* w w w .j a va 2s . 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 ww .j a v a 2 s. co 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 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 + "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 w 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 + "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:test.itext.html.AimsPdf.java
License:Open Source License
public static void addTitle(Document doc, String text) throws IOException, BadElementException, DocumentException { float[] widths = { 62f, 164f, 62f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100);/* w ww . j a va2s .co m*/ table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setSpacingAfter(10); Image image = Image.getInstance("app_title.gif"); image.scalePercent(70); PdfPCell cell = new PdfPCell(image); cell.setPadding(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); Paragraph title = new Paragraph(text, FontFactory.getFont("arial", 12, Font.BOLD)); cell = new PdfPCell(title); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); image = Image.getInstance("title_shot.gif"); image.scalePercent(70); cell = new PdfPCell(image); cell.setPadding(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); doc.add(table); table = new PdfPTable(1); table.setWidthPercentage(100); cell = new PdfPCell(); cell.setBackgroundColor(Color.BLACK); cell.setFixedHeight(1); table.addCell(cell); doc.add(table); }
From source file:tk.diginspect.main.SoOFSignatories.java
public void createPDF() { doc = new Document(PageSize.A4); try {/*from w w w. j a v a 2s.com*/ String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/RFO"; File dir = new File(path); if (!dir.exists()) { dir.mkdirs(); } String strFinalname, strFilename2, strFilenames; String filename = sp.getString("EstablishmentName", null); String strfilename = filename.replaceAll("\\W+", "-"); String inspector = sp.getString("FDRO1", null); String inspby = inspector.replaceAll("\\W+", "-"); File file = new File(dir, strfilename + "-" + strFile + "-" + inspby + ".pdf"); strFilename2 = strfilename + "-" + strFile + "-" + inspby; strFilenames = strFilename2 + ".pdf"; strFinalname = path + "/" + strFilenames; savePreferences("fileName", strFinalname); FileOutputStream fOut = new FileOutputStream(file); PdfWriter.getInstance(doc, fOut); doc.open(); FDALetterhead(); // General Info Table float[] table1columnWidths = { 1f, 1f, 1f, 1f }; PdfPTable table1 = new PdfPTable(table1columnWidths); table1.setWidthPercentage(110f); table1.setSpacingAfter(20f); insertCell(table1, "INSPECTION REPORT", Element.ALIGN_CENTER, 4, "#8EBAFF", 1, 0); insertCell(table1, "Name of Establishment", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("EstablishmentName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Plant/Office Address", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PlantOfficeAddress", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Warehouse Address", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("WarehouseAddress", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Owner", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Owner", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Telephone Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("TelNumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Fax No", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("FaxNumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Classification", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); String Classification = sp.getString("MainClass", null) + ", " + sp.getString("SecClass", null) + ", " + sp.getString("ThirdClass", null) + ", " + sp.getString("FourthClass", ""); insertCell(table1, Classification, Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Product/s:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Products", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Manner of Notification", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Notification", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Purpose of Inspection", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("Inspection", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Registered Pharmacist / Authorized Representative / Person", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "Name", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PharmacistName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Reg. No. (PRC-ID)", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcID", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Date Issued", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcDateIssued", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Validity", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PrcValidity", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Position", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("PharmacistPosition", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Person/s Interviewed", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("InterviewedName", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Position", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("InterviewedPosition", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "License to Operate", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTONumber", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Renewal", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTORenewalDate", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Validity", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("LTOValidity", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Payment of Appropriate Fee", Element.ALIGN_LEFT, 4, "#8EBAFF", 1, 0); insertCell(table1, "OR Number", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("ORNum", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Amount", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell(table1, "Php " + sp.getString("ORAmount", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "Date of Payment", Element.ALIGN_LEFT, 0, "#8EBAFF", 1, 0); insertCell(table1, sp.getString("ORDate", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 0); insertCell(table1, "RSN", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 1); insertCell(table1, sp.getString("RSN", "N/A"), Element.ALIGN_LEFT, 3, "#FFFFFF", 1, 1); doc.add(table1); footer(); // 2nd Page doc.newPage(); FDALetterhead(); PdfPTable table2 = new PdfPTable(1); table2.setWidthPercentage(110f); table2.setSpacingAfter(20f); insertCell(table2, "Observation Findings:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 0); insertCell1(table2, sp.getString("ObservationFindings", ""), 1, 1, 600f); doc.add(table2); footer(); // 3rd Page doc.newPage(); FDALetterhead(); PdfPTable table3 = new PdfPTable(1); table3.setWidthPercentage(110f); table3.setSpacingAfter(20f); insertCell(table3, "Directives:", Element.ALIGN_LEFT, 1, "#8EBAFF", 1, 1); nested(table3, 0.1f, 2f, R.string.directives1, sp.getBoolean("Directives1", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives2, sp.getBoolean("Directives2", false), Element.ALIGN_LEFT); nested(table3, 0.2f, 2f, R.string.directives3, sp.getBoolean("Directives3", false), Element.ALIGN_RIGHT); nested(table3, 0.2f, 2f, R.string.directives4, sp.getBoolean("Directives4", false), Element.ALIGN_RIGHT); nested(table3, 0.1f, 2f, R.string.directives5, sp.getBoolean("Directives5", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives6, sp.getBoolean("Directives6", false), Element.ALIGN_LEFT); nested(table3, 0.1f, 2f, R.string.directives7, sp.getBoolean("Directives7", false), Element.ALIGN_LEFT); String Directives8 = getResources().getString(R.string.directives8); PdfPCell cellDirectives8 = new PdfPCell(new Paragraph(Font.TIMES_ROMAN, Directives8)); cellDirectives8.setPaddingLeft(50); cellDirectives8.setPaddingTop(5); cellDirectives8.setPaddingBottom(5); cellDirectives8.setPaddingRight(5); cellDirectives8.setBorderWidthTop(0); cellDirectives8.setBorderWidthBottom(0); table3.addCell(cellDirectives8); String Directives = sp.getString("Directives8", null); boolean Directives9 = false, Directives10 = false; if (Directives.equals(R.string.directives9)) { Directives9 = true; Directives10 = false; } else if (Directives.equals(R.string.directives10)) { Directives9 = false; Directives10 = true; } else { Directives9 = false; Directives10 = false; } nested(table3, 0.3f, 2f, R.string.directives9, Directives9, Element.ALIGN_RIGHT); nested(table3, 0.3f, 2f, R.string.directives10, Directives10, Element.ALIGN_RIGHT); insertCell(table3, "Inspected By:", Element.ALIGN_CENTER, 1, "#8EBAFF", 1, 0); PdfPTable signature1 = new PdfPTable(2); sig(signature1, "FDRO1"); sig(signature1, "FDRO2"); insertCell(signature1, sp.getString("FDRO1", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, sp.getString("FDRO2", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, "Food-Drug Regulation Officer", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Food-Drug Regulation Officer", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Date: " + dateStarted, Element.ALIGN_LEFT, 1, "#FFFFFF", 1, 0); insertCell(signature1, "Time: " + timeS, Element.ALIGN_LEFT, 1, "#FFFFFF", 1, 0); sig(signature1, "EstRep1"); sig(signature1, "EstRep2"); insertCell(signature1, sp.getString("EstRep1", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, sp.getString("EstRep2", null), Element.ALIGN_CENTER, 1, "#FFFFFF", 0, 0); insertCell(signature1, "Establishments Representative", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); insertCell(signature1, "Establishments Representative", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); PdfPCell nesthousing1 = new PdfPCell(signature1); table3.addCell(nesthousing1); doc.add(table3); footer(); // 4th Page doc.newPage(); FDALetterhead(); PdfPTable table4 = new PdfPTable(1); table4.setWidthPercentage(110f); table4.setSpacingAfter(20f); insertCell(table4, "(FDA USE ONLY)", Element.ALIGN_CENTER, 1, "#8EBAFF", 1, 1); insertCell(table4, "Compliance Made by the Company", Element.ALIGN_LEFT, 1, "#FFFFFF", 0, 0); nested(table4, 0.1f, 2f, R.string.CAPA, false, Element.ALIGN_LEFT); nested(table4, 0.2f, 2f, R.string.Accepted, false, Element.ALIGN_RIGHT); nested(table4, 0.2f, 2f, R.string.NotAccepted, false, Element.ALIGN_RIGHT); insertCell(table4, "Recommendation (to Licensing) :", Element.ALIGN_LEFT, 1, "#FFFFFF", 0, 0); insertCell1(table4, "", 0, 0, 100f); PdfPTable signature2 = new PdfPTable(2); insertCell1(signature2, "", 0, 0, 50f); insertCell1(signature2, "", 0, 0, 50f); insertCell(signature2, "Print Name & Signature of FDRO/s", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature2, "Date", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 0); insertCell(signature2, "Reviewed by:", Element.ALIGN_LEFT, 2, "#8EBAFF", 1, 1); insertCell1(signature2, "", 0, 0, 50f); insertCell1(signature2, "", 0, 0, 50f); insertCell(signature2, "Print Name & Signature of Team Leader/Supervisor", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); insertCell(signature2, "Date", Element.ALIGN_CENTER, 1, "#FFFFFF", 1, 1); PdfPCell nesthousing2 = new PdfPCell(signature2); table4.addCell(nesthousing2); doc.add(table4); footer(); } catch (DocumentException de) { Log.e("PDFCreator", "DocumentException:" + de); } catch (FileNotFoundException e) { Log.e("PDFCreator", "ioException:" + e); } finally { doc.close(); } }
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 www . ja v a 2s . 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; 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// ww w.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; 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();// ww w.j ava 2 s . c o m 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(); }