List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:printom.PDFCreator.java
public static void createLabel(int aLabelType, int aJobNum, char aJobIdentifier, String aCustName, String aItemName, String aItemCode, String aDate, String aPOrderNum, int aInputPcs) { String myJobNum = String.valueOf(aJobNum); char myJobIdentifier = aJobIdentifier; String myCustName = aCustName; String myItemName = aItemName; String myItemCode = aItemCode; String myDate = aDate;// w w w .j av a 2s .co m String myPOrderNum = aPOrderNum; String myInputPcs = String.valueOf(aInputPcs); try { String src = ""; if (aLabelType == 1) { src = CTNLABEL; } String dest = RESULTLABEL; Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.WHITE); Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfContentByte canvas = stamper.getOverContent(1); for (int k = 0; k < 3; k++) { //Positions int[] x = { 298, 350, 125, 80, 80, 80, 80, 120 }; int[] y = { 562, 562, 518, 498, 479, 459, 440, 420 }; if (k == 1) { for (int j = 0; j < 8; j++) { y[j] = y[j] - 186; } } if (k == 2) { for (int j = 0; j < 8; j++) { y[j] = y[j] - 372; } } for (int i = 0; i < 2; i++) { if (i == 1) { for (int j = 0; j < 8; j++) { x[j] = x[j] + 372; } } ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myJobNum, timesJob), x[0], y[0], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(String.valueOf(myJobIdentifier), timesDef), x[1], y[1], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myCustName, timesDef), x[2], y[2], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemName, timesDef), x[3], y[3], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemCode, timesDef), x[4], y[4], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myDate, timesDef), x[5], y[5], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myPOrderNum, timesDef), x[6], y[6], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputPcs, timesDef), x[7], y[7], 0); } } stamper.close(); reader.close(); } catch (IOException | DocumentException ex) { Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:printom.PDFCreator.java
public static void createReport(int aJobNum, char aJobIdentifier, String aCustName, String aItemName, String aItemCode, String aDate, String aPOrderNum, int aInputPcs, int aQtyWithOvers, int aNumContainers, String aInputContainer) { String myJobNum = String.valueOf(aJobNum); char myJobIdentifier = aJobIdentifier; String myCustName = aCustName; String myItemName = aItemName; String myItemCode = aItemCode; String myDate = aDate;/*w w w. j av a2s. c om*/ String myPOrderNum = aPOrderNum; String myInputPcs = String.valueOf(aInputPcs); int myQtyWithOvers = aQtyWithOvers; int myNumContainers = aNumContainers; String myInputContainer = aInputContainer; double amount = myQtyWithOvers; DecimalFormat formatter = new DecimalFormat("#,###"); String myStrQtyWithOvers = formatter.format(amount); try { String src = REPORT; String dest = RESULTREPORT; Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, BaseColor.WHITE); Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); PdfContentByte canvas = stamper.getOverContent(1); int[] x = { 441, 510, 426, 87, 87, 87, 426, 307, 218, 325, 426 }; int[] y = { 547, 547, 473, 450, 428, 473, 450, 325, 385, 385, 428 }; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myJobNum, timesJob), x[0], y[0], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(String.valueOf(myJobIdentifier), timesDef), x[1], y[1], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myCustName, timesDef), x[2], y[2], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemName, timesDef), x[3], y[3], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myItemCode, timesDef), x[4], y[4], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myDate, timesDef), x[5], y[5], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myPOrderNum, timesDef), x[6], y[6], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputPcs, timesDef), x[7], y[7], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myStrQtyWithOvers, timesDef), x[8], y[8], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("(" + String.valueOf(myNumContainers) + " cases with overs)", timesDef), x[9], y[9], 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myInputContainer, timesDef), x[10], y[10], 0); stamper.close(); reader.close(); } catch (IOException | DocumentException ex) { Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:printom.PDFCreator.java
public static void createBOL(ArrayList<Shipment> aShipmentList, int aTemplate) { ArrayList<Shipment> shipmentList = aShipmentList; Order chosenOrder = shipmentList.get(0).getChosenOrder(); String bolCode = shipmentList.get(0).getBolCode(); String bolFileName = bolCode + ".pdf"; String myCustName = Customer.getCustomerName(chosenOrder.getCustID()); String myShipDate = Prompter.dateString(shipmentList.get(0).getDateShipped()); String myCarrier = shipmentList.get(0).getCarrier(); String myInstructs = shipmentList.get(0).getInstructions(); Address myAddress = Address.retAddress(shipmentList.get(0).getChosenOrder().getShipAddressID()); try {/*from www . j a v a2s . c o m*/ //BaseFont bf1 = BaseFont.createFont("c:/windows/fonts/consola.ttf", //BaseFont.WINANSI, BaseFont.EMBEDDED); Font timesJob = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD, BaseColor.WHITE); Font timesDef = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); Font courierNorm = new Font(Font.FontFamily.COURIER, 11, Font.NORMAL, BaseColor.BLACK); Font courierSBig = new Font(Font.FontFamily.COURIER, 13, Font.NORMAL, BaseColor.BLACK); // step 1 Document document = new Document(PageSize.LETTER, 18, 18, 126, 54); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(bolFileName)); // step 3 document.open(); // step 4 // we set the compression to 0 so that we can read the PDF syntax writer.setCompressionLevel(0); // writes something to the direct content using a convenience method PdfContentByte canvas = writer.getDirectContentUnder(); // Graphic Letterheard Image image = Image.getInstance("AresLH.jpg"); image.scalePercent(50f); image.setAbsolutePosition(43, 680); if (aTemplate == 1) document.add(image); // 11" = 792 // 8.5 = 612 // TEXT SIZE = 11 // LINE SPACING = 11 // PARAGRAPH SPACE = 3 * 11 int myPageWidth = 612; int myPageHeight = 792; int myTopMargin = 655; int myTopSubMargin = 622; int myPageLeftMargin = 54; // HEADER LINES ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ARES BOL# " + bolCode, courierNorm), myPageLeftMargin, myTopMargin, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("DATE: " + myShipDate, courierNorm), myPageWidth - myPageLeftMargin, myTopMargin, 0); // CONSIGNEE ADDRESS int myAddressStartY = myTopSubMargin; int myCurrentY = myTopSubMargin; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CONSIGNEE", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ADDRESS:", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY = myAddressStartY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getAttention(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getAddress1(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getCity() + ", " + myAddress.getState() + " " + myAddress.getZipCode(), courierNorm), 125, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(myAddress.getLastLine(), courierNorm), 125, myCurrentY, 0); // FROM ADDRESS myCurrentY = myAddressStartY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FROM:", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Ares Printing & Packaging", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("63 Flushing Ave, Bldg 5", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn Navy Yard", courierNorm), 98 + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("Brooklyn, NY 11205", courierNorm), 98 + 288, myCurrentY, 0); // CARRIER, FOB AND SPECIAL INSTRUCTIONS myCurrentY -= 33; int myItemStartY = myCurrentY; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CARRIER: " + myCarrier, courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("FOB: Brooklyn", courierNorm), myPageLeftMargin, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("SPECIAL INSTRUCTIONS: " + myInstructs, courierNorm), myPageLeftMargin, myCurrentY, 0); int myBOLTPallets = 0; int myBOLTCases = 0; int myBOLTPieces = 0; myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); // Start Item/ShipLine Information for (Shipment shipment : shipmentList) { ArrayList<Inventory> shipInventoryList = shipment.getInvenList(); ArrayList<Inventory.InventoryLine> invenLineList = new ArrayList<>(); Item item = new Item(shipInventoryList.get(0).getItemID()); String apo = ""; for (int i = 0; i < shipInventoryList.size(); i++) { if (i == 0) { apo += shipInventoryList.get(i).getJobNum(); } else { apo += ", " + shipInventoryList.get(i).getJobNum(); } invenLineList.addAll(shipInventoryList.get(i).getInvenLines()); } //START ITEM myCurrentY -= 22; if (myCurrentY < 100) { document.newPage(); if (aTemplate == 1) { document.add(image); } myCurrentY = myTopSubMargin; } ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: " + item.getItemName(), courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: " + chosenOrder.getPOrderNum(), courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: " + item.getItemCode(), courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: " + apo, courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; int myItemTPallets = 0; int myItemTCases = 0; int myItemTPieces = 0; for (Inventory.InventoryLine invenLine : invenLineList) { ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getPallets()), courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getCases()), courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase(String.valueOf(invenLine.getPieces()), courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; myItemTPallets += invenLine.getPallets(); myItemTCases += invenLine.getPallets() * invenLine.getCases(); myItemTPieces += invenLine.getPallets() * invenLine.getCases() * invenLine.getPieces(); myBOLTPallets += myItemTPallets; myBOLTCases += myItemTCases; myBOLTPieces += myItemTPieces; } myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned( canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: " + myItemTPallets + " CASES: " + myItemTCases + " QUANTITY: " + myItemTPieces, courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); ////////////// //END ITEM ////////////// myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ////////////// //START ITEM ////////////// ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// */ ////////////// //START FOOTER ////////////// myCurrentY -= 33; if (myCurrentY < 85) { document.newPage(); myCurrentY = myTopSubMargin; } ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("SHIPMENT RECEIVED IN GOOD CONDITION BY:", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("______________________________________", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY -= 16; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("(SIGNATURE) (DATE & TIME)", courierNorm), myPageLeftMargin + 128, myCurrentY, 0); myCurrentY += 49; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL PALLETS: " + myBOLTPallets, courierSBig), myPageLeftMargin + 500, myCurrentY, 0); myCurrentY -= 13; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL CASES: " + myBOLTCases, courierSBig), myPageLeftMargin + 500, myCurrentY, 0); myCurrentY -= 13; ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, new Phrase("TOTAL WEIGHT: ~" + ((myBOLTCases * 25) + (myBOLTPallets * 40)) + " lbs", courierSBig), myPageLeftMargin + 500, myCurrentY, 0); ////////////// //END FOOTER ////////////// /* document.newPage(); myCurrentY = myTopSubMargin; ////////////// //START ITEM ////////////// ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); //START ITEM myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM NAME: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("CUSTOMER PO#: 2011444", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM CODE: ZCART-248", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("APO: 14900", courierNorm), myPageLeftMargin + 288, myCurrentY, 0); myCurrentY -= 22; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pallets", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Cases per pallet", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("Pieces per case", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 6; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); // ITEM 1 myCurrentY -= 12; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("11", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("24", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); // LINE 2 myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("1", courierNorm), myPageLeftMargin + 115, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 150, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("18", courierNorm), myPageLeftMargin + 215, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("@", courierNorm), myPageLeftMargin + 281, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, new Phrase("180", courierNorm), myPageLeftMargin + 340, myCurrentY, 0); myCurrentY -= 1; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("_______________________________________________", courierNorm), myPageLeftMargin + 85, myCurrentY, 0); myCurrentY -= 33; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("ITEM TOTALS:", courierNorm), myPageLeftMargin, myCurrentY, 0); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(" PALLETS: 12 CASES: 282 QUANTITY: 50,760", courierNorm), myPageLeftMargin + 95, myCurrentY, 0); myCurrentY -= 11; ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("---------------------------------------------------------------------------", courierNorm), myPageLeftMargin, myCurrentY, 0); ////////////// //END ITEM ////////////// */ // step 5 document.close(); if (Desktop.isDesktopSupported()) { try { File f = new File(bolFileName); Desktop.getDesktop().open(f); } catch (IOException ex) { // no application registered for PDFs } } } catch (IOException | DocumentException ex) { Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:PROCESOS.ImprimirPDF.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/pdf"); String precio_unitario = request.getParameter("precio"); String id_vale = request.getParameter("codigo"); // if(request.getParameter("codigo")!=null){ OutputStream salida = response.getOutputStream(); try {/*from w w w . j a v a2s . c o m*/ try { DTO.ClaseTransaccion clase = new ClaseTransaccion(); clase = consulta.Transaccion(); Document documento = new Document(PageSize.A4, 36, 36, 45, 20); PdfWriter pw = PdfWriter.getInstance(documento, salida); documento.open(); Paragraph parrafo1 = new Paragraph(); Font font_titulo = new Font(Font.FontFamily.HELVETICA, 16, Font.UNDERLINE, BaseColor.BLACK); parrafo1.add(new Phrase("TecnoBencina, COMPROBANTE", font_titulo)); parrafo1.setAlignment(Element.ALIGN_CENTER); parrafo1.add(new Phrase(Chunk.NEWLINE)); parrafo1.add(new Phrase(Chunk.NEWLINE)); documento.add(parrafo1); Paragraph parrafo2 = new Paragraph(); Font font_titulo_p2 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK); if (id_vale.length() > 0) { parrafo2.add(new Phrase("Comprobante de transaccion : codigo del vale : " + id_vale, font_titulo_p2)); } else { parrafo2.add(new Phrase("Comprobante de transaccion ", font_titulo_p2)); } parrafo2.setAlignment(Element.ALIGN_JUSTIFIED); parrafo2.add(new Phrase(Chunk.NEWLINE)); parrafo2.add(new Phrase(Chunk.NEWLINE)); parrafo2.add(new Phrase(Chunk.NEWLINE)); documento.add(parrafo2); PdfPTable tabla = new PdfPTable(9); PdfPCell celda1 = new PdfPCell(new Paragraph("ID transaccion ", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda2 = new PdfPCell( new Paragraph("Estado ", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda3 = new PdfPCell(new Paragraph("ID de surtidor", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda4 = new PdfPCell( new Paragraph("Litros", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda5 = new PdfPCell( new Paragraph("Monto", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda6 = new PdfPCell( new Paragraph("Fecha", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda7 = new PdfPCell( new Paragraph("ID pago", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda8 = new PdfPCell(new Paragraph("Precio unitario", FontFactory.getFont("Arial", 12, Font.BOLD, BaseColor.BLACK))); tabla.addCell(celda1); tabla.addCell(celda2); tabla.addCell(celda3); tabla.addCell(celda4); tabla.addCell(celda5); tabla.addCell(celda6); tabla.addCell(celda7); tabla.addCell(celda8); tabla.addCell(String.valueOf(clase.getId_transaccion())); tabla.addCell(clase.getEstado()); tabla.addCell(String.valueOf(clase.getId_transaccion())); tabla.addCell(String.valueOf(clase.getLitros())); tabla.addCell(String.valueOf(clase.getMonto())); tabla.addCell(String.valueOf(clase.getFecha())); tabla.addCell(String.valueOf(clase.getId_pago())); tabla.addCell(precio_unitario); documento.add(tabla); documento.addAuthor("TecnoBencina"); documento.addTitle("Comprobante"); documento.addLanguage("Espaol"); documento.add(new Paragraph(new Phrase(Chunk.NEWLINE))); documento.add(new Paragraph(new Phrase(Chunk.NEWLINE))); documento.add(new Paragraph(new Phrase(Chunk.NEWLINE))); documento.add(new Paragraph(new Phrase(Chunk.NEWLINE))); documento.add(new Paragraph("texto....", font_titulo_p2)); documento.close(); } catch (Exception s) { s.getMessage(); } } catch (Exception s) { System.out.println("" + s.getMessage()); } finally { salida.close(); } // } }
From source file:quanlyhoadon.PDFProcess.java
public boolean printPDF(String dest, Company company, Bill bill, LinhTinh lt) { try {//from w w w . j ava 2 s .c o m BaseFont urName = BaseFont.createFont("font/Time_New_Roman.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font nameFont = new Font(urName, 16, Font.BOLD); Font addFont = new Font(urName, 12); Font boldFont = new Font(urName, 14, Font.BOLD); Font contentFont = new Font(urName, 14); Font footFont = new Font(urName, 16); Document document = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.setWidths(new float[] { 2, 6, 3 }); //logo Image img = Image.getInstance("logo.jpg"); img.scaleAbsolute(100, 100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); //middle content String name = company.getName(); String address = "\n\n?C: " + company.getAddress(); String phone = "\n\n?T: " + company.getPhone(); String hed = "\n\n PHIU B?O GI?"; Phrase mid = new Phrase(); mid.add(new Chunk(name, nameFont)); mid.add(new Chunk(address + phone, addFont)); mid.add(new Chunk(hed, nameFont)); PdfPCell midCell = new PdfPCell(mid); // midCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); midCell.setPaddingTop(15); midCell.setPaddingLeft(40); midCell.setPaddingRight(15); midCell.setPaddingBottom(15); midCell.setBorder(PdfPCell.NO_BORDER); // right content String soCt = "S CT: " + bill.getId(); String date = "\n\nNgy: " + bill.getDate() + "\n\nKho : " + lt.getKho(); Phrase right = new Phrase(); right.add(new Chunk(soCt + date, addFont)); PdfPCell rightCell = new PdfPCell(right); rightCell.setPadding(15); rightCell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); table.addCell(midCell); table.addCell(rightCell); document.add(table); Phrase p1 = new Phrase(); p1.add(new Chunk("?n v: ", addFont)); p1.add(new Chunk(lt.getDonVi(), boldFont)); p1.add(new Chunk("\n?a Ch: \n", addFont)); Paragraph pagra = new Paragraph(p1); pagra.setIndentationLeft(15); pagra.setSpacingBefore(10); pagra.setSpacingAfter(10); document.add(pagra); //table lt PdfPTable tablList = new PdfPTable(6); tablList.setWidthPercentage(100); tablList.setWidths(new float[] { 1, 5, 7, 2, 3, 4 }); String title[] = { "STT", "M Hng", "Tn Hng", "SL", "?n Gi", "Thnh Ti?n" }; for (int i = 0; i < title.length; ++i) { Phrase phr = new Phrase(); phr.add(new Chunk(title[i], boldFont)); PdfPCell p = new PdfPCell(phr); p.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(p); } //--- add content for (int i = 0; i < bill.getCount(); ++i) { Phrase[] phrase = new Phrase[6]; PdfPCell[] pCell = new PdfPCell[6]; for (int k = 0; k < 6; ++k) { phrase[k] = new Phrase(); } phrase[0].add(new Chunk((i + 1) + "", contentFont)); phrase[1].add(new Chunk(bill.getMaHangAt(i), contentFont)); phrase[2].add(new Chunk(bill.getTenHangAt(i), contentFont)); phrase[3].add(new Chunk(bill.getSoLuongAt(i) + "", contentFont)); phrase[4].add(new Chunk(bill.getDonGiaAt(i) + "", contentFont)); phrase[5].add(new Chunk(bill.getThanhTienAt(i) + "", contentFont)); for (int j = 0; j < 6; ++j) { pCell[j] = new PdfPCell(phrase[j]); pCell[j].setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(pCell[j]); } } PdfPCell cell1 = new PdfPCell(new Phrase(new Chunk("Tng", boldFont))); cell1.setColspan(3); cell1.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(cell1); // PdfPCell cell2 = new PdfPCell(new Phrase(new Chunk("" + bill.getTong(), boldFont))); cell2.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(cell2); // PdfPCell cell3 = new PdfPCell(new Phrase(new Chunk("", boldFont))); cell3.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(cell3); // PdfPCell cell4 = new PdfPCell(new Phrase(new Chunk(String.format("%,d", bill.tongTien()), boldFont))); cell4.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tablList.addCell(cell4); document.add(tablList); //-------------------in phuong thuc thanh toan Phrase p2 = new Phrase(); p2.add(new Chunk("Phng thc thanh ton: ", contentFont)); p2.add(new Chunk(lt.getThanhToan(), boldFont)); p2.add(new Chunk("\nLu mua hng min tr li. Vui lng gi phiu trong 7 ngy: ", contentFont)); Paragraph pagra2 = new Paragraph(p2); pagra2.setSpacingBefore(5); pagra2.setSpacingAfter(5); document.add(pagra2); //---- footer content PdfPTable tblFoot = new PdfPTable(3); tblFoot.setWidthPercentage(100); tblFoot.setWidths(new float[] { 1, 1, 1 }); PdfPCell leftFootCell = new PdfPCell(new Phrase(new Chunk("NGI LP ", footFont))); PdfPCell midFootCell = new PdfPCell(new Phrase(new Chunk("K TO?N ", footFont))); PdfPCell rightFootCell = new PdfPCell(new Phrase(new Chunk("TH TRNG ?N V ", footFont))); leftFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); leftFootCell.setBorder(PdfPCell.NO_BORDER); midFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); midFootCell.setBorder(PdfPCell.NO_BORDER); rightFootCell.setBorder(PdfPCell.NO_BORDER); rightFootCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tblFoot.addCell(leftFootCell); tblFoot.addCell(midFootCell); tblFoot.addCell(rightFootCell); document.add(tblFoot); // document.close(); JOptionPane.showMessageDialog(null, "In hoadon.pdf thnh cng"); return true; } catch (Exception e) { JOptionPane.showMessageDialog(null, "hoadon.pdf ang c m\nVui lng ng li. Sau th li"); e.printStackTrace(); return false; } }
From source file:relatorios.RelatorioCliente.java
public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento Document document = new Document(PageSize.A4, 30, 20, 20, 30); Connection conecta; // o objeto que conecta com o banco de dados PreparedStatement pst;/*w w w .ja v a2 s . c o m*/ ResultSet rs; conecta = ConectaBd.conectabd(); OutputStream output; try { output = new FileOutputStream("relatorios/Relatrio de Clientes.pdf"); try { PdfWriter.getInstance(document, output); document.open(); // adicionando um pargrafo ao documento document.add(new Paragraph(" Relatrio de Clientes")); document.add(new Paragraph("\n")); Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0)); Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8); PdfPTable tabela = new PdfPTable(6); PdfPCell cell; cell = new PdfPCell(new Phrase("Nome", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("CPF", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Endereo", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Cidade", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("UF", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Telefone", bfBold10)); tabela.addCell(cell); String sql = "Select * from clientes order by codigo Asc"; //orderna pelo numero do codigo ascendentemente try { pst = conecta.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String fornec = rs.getString("nome"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("cpf"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("endereco"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("cidade"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("uf"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("telefone"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); } } catch (SQLException error) { JOptionPane.showMessageDialog(null, error); } document.add(tabela); document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); document.close(); } } catch (FileNotFoundException ex) { Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }
From source file:relatorios.RelatorioCompra.java
public static void gerarRelatorio(String sql) throws ClassNotFoundException { // criao do objeto documento Document document = new Document(PageSize.A4, 30, 20, 20, 30); Connection conecta; // o objeto que conecta com o banco de dados PreparedStatement pst;/*from w ww . j a v a2s .co m*/ ResultSet rs; conecta = ConectaBd.conectabd(); OutputStream output; try { output = new FileOutputStream("relatorios/Relatrio de Compras.pdf"); try { PdfWriter.getInstance(document, output); document.open(); // adicionando um pargrafo ao documento document.add(new Paragraph(" Relatrio de Compras")); document.add(new Paragraph("\n")); Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0)); Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 6); PdfPTable tabela = new PdfPTable(6); PdfPCell cell; cell = new PdfPCell(new Phrase("Fornecedor", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Produto", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Qtde do Produto", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Valor por Unidade", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Valor Total", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Data", bfBold10)); tabela.addCell(cell); try { pst = conecta.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String fornec = rs.getString("fornecedor"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("produto"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("quantidade"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("valorunitariocompra"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("valortotalcompra"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("data_compra"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); } } catch (SQLException error) { JOptionPane.showMessageDialog(null, error); } document.add(tabela); document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); document.close(); } } catch (FileNotFoundException ex) { Logger.getLogger(RelatorioCompra.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }
From source file:relatorios.RelatorioFornecedor.java
public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento Document document = new Document(PageSize.A4, 30, 20, 20, 30); Connection conecta; // o objeto que conecta com o banco de dados PreparedStatement pst;/*from w ww.j ava 2 s . c o m*/ ResultSet rs; conecta = ConectaBd.conectabd(); OutputStream output; try { output = new FileOutputStream("relatorios/Relatrio de Fornecedores.pdf"); try { PdfWriter.getInstance(document, output); document.open(); // adicionando um pargrafo ao documento document.add(new Paragraph(" Relatrio de Fornecedores")); document.add(new Paragraph("\n")); Font bfBold10 = new Font(FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0)); Font bf8 = new Font(FontFamily.TIMES_ROMAN, 8); PdfPTable tabela = new PdfPTable(7); PdfPCell cell; cell = new PdfPCell(new Phrase("Fornecedor", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("CPF", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("CNPJ", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Endereo", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Cidade", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Email", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Telefone", bfBold10)); tabela.addCell(cell); String sql = "Select * from fornecedores order by codigo Asc"; //orderna pelo numero do codigo ascendentemente try { pst = conecta.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String fornec = rs.getString("fornecedor"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("cpf"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("cnpj"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("endereco"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("cidade"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("email"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("telefone"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); } } catch (SQLException error) { JOptionPane.showMessageDialog(null, error); } document.add(tabela); document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); document.close(); } } catch (FileNotFoundException ex) { Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }
From source file:relatorios.RelatorioFuncionario.java
public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento Document document = new Document(PageSize.A4, 30, 20, 20, 30); Connection conecta; // o objeto que conecta com o banco de dados PreparedStatement pst;//w ww . j a va2 s . c om ResultSet rs; conecta = ConectaBd.conectabd(); OutputStream output; try { output = new FileOutputStream("relatorios/Relatrio de Funcionarios.pdf"); try { PdfWriter.getInstance(document, output); document.open(); // adicionando um pargrafo ao documento document.add(new Paragraph(" Relatrio de Funcionarios")); document.add(new Paragraph("\n")); Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0)); Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8); PdfPTable tabela = new PdfPTable(3); PdfPCell cell; cell = new PdfPCell(new Phrase("Nome", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Telefone", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Usuario", bfBold10)); tabela.addCell(cell); String sql = "Select * from funcionarios order by codigo Asc"; //orderna pelo numero do codigo ascendentemente try { pst = conecta.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String fornec = rs.getString("nome"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("telefone"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("usuario"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); } } catch (SQLException error) { JOptionPane.showMessageDialog(null, error); } document.add(tabela); document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); document.close(); } } catch (FileNotFoundException ex) { Logger.getLogger(RelatorioFornecedor.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }
From source file:relatorios.RelatorioProdutos.java
public static void gerarRelatorio() throws ClassNotFoundException { // criao do objeto documento Document document = new Document(PageSize.A4, 30, 20, 20, 30); Connection conecta; // o objeto que conecta com o banco de dados PreparedStatement pst;// w ww . ja v a2 s.c om ResultSet rs; conecta = ConectaBd.conectabd(); OutputStream output; try { output = new FileOutputStream("relatorios/Relatrio de Produtos.pdf"); try { PdfWriter.getInstance(document, output); document.open(); // adicionando um pargrafo ao documento document.add(new Paragraph(" Relatrio de Produtos")); document.add(new Paragraph("\n")); Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, new BaseColor(0, 0, 0)); Font bf8 = new Font(Font.FontFamily.TIMES_ROMAN, 8); PdfPTable tabela = new PdfPTable(4); PdfPCell cell; cell = new PdfPCell(new Phrase("Nome", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Valor de Compra", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Valor de Venda", bfBold10)); tabela.addCell(cell); cell = new PdfPCell(new Phrase("Qtde. em Estoque", bfBold10)); tabela.addCell(cell); String sql = "Select * from produtos_float order by codigo Asc"; //orderna pelo numero do codigo ascendentemente try { pst = conecta.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String fornec = rs.getString("descricao"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("valor_compra"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("valor_venda"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); fornec = rs.getString("estoque"); cell = new PdfPCell(new Phrase(fornec, bf8)); tabela.addCell(cell); } } catch (SQLException error) { JOptionPane.showMessageDialog(null, error); } document.add(tabela); document.close(); } catch (DocumentException de) { System.err.println(de.getMessage()); document.close(); } } catch (FileNotFoundException ex) { Logger.getLogger(RelatorioProdutos.class.getName()).log(Level.SEVERE, null, ex); System.err.println(ex.getMessage()); } }