List of usage examples for com.itextpdf.text Font NORMAL
int NORMAL
To view the source code for com.itextpdf.text Font NORMAL.
Click Source Link
From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java
protected void printKeyData(SessionContainerWO sessionContainerWO) { try {//ww w. j a v a2 s . co m doc.add(new Paragraph(" ")); table = new PdfPTable(15); table.setWidthPercentage(100); // kernel-data cell = new PdfPCell(new Paragraph(getTran("Web.Occup", "medwan.common.kernel-data").toUpperCase(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(15); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell); // row 1 : last-periodical-examination Paragraph par = new Paragraph( getTran("Web.Occup", "medwan.common.last-periodical-examination").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); TransactionVO tran = sessionContainerWO.getLastTransaction(IConstants_PREFIX + "TRANSACTION_TYPE_MER"); ItemVO item; if (tran != null) { item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_MER_EXAMINATION_DATE"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); } } cell = new PdfPCell(par); cell.setColspan(5); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 1 : next-periodical-examination par = new Paragraph( getTran("Web.Occup", "medwan.common.next-periodical-examination").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); if (sessionContainerWO.getFlags().getLastExaminationReport() != null && sessionContainerWO.getFlags() .getLastExaminationReport().getNewExaminationDueDate() != null) { par.add(new Chunk( dateFormat.format(sessionContainerWO.getFlags().getLastExaminationReport() .getNewExaminationDueDate()), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); } cell = new PdfPCell(par); cell.setColspan(5); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 1 : next-driver-examination / Volgend onderzoek medische schifting par = new Paragraph(getTran("Web.Occup", "medwan.common.next-driver-examination").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); if (sessionContainerWO.getFlags().getLastDrivingCertificate() != null) { // CBMT only : only display newExaminationDueDate if patient has riskcode "070" (drivinglicense) boolean riskCode070Found = false; if (riskCode070Found) { String newExamDueDateMinus = ScreenHelper.checkString(sessionContainerWO.getFlags() .getLastDrivingCertificate().getNewExaminationDueDateMinus()); if (newExamDueDateMinus.length() > 0) { par.add(new Chunk(newExamDueDateMinus.replaceAll("-", "/"), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); } } } else { // no data available par.add(new Chunk(getTran("Web.Occup", "medwan.common.no-data"), FontFactory.getFont( FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); } cell = new PdfPCell(par); cell.setColspan(5); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 2 : Biometrie par = new Paragraph(getTran("Web.Occup", "medwan.common.biometry").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); tran = sessionContainerWO.getLastTransactionTypeBiometry(); if (tran != null) { // height item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_HEIGHT"); String sHeight = "", sWeight = ""; if (item != null) { sHeight = item.getValue(); par.add(new Chunk(getTran("Web.Occup", "medwan.common.length") + ": " + sHeight + " cm\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } // weight item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_WEIGHT"); if (item != null) { sWeight = item.getValue(); par.add(new Chunk(getTran("Web.Occup", "medwan.common.weight") + ": " + sWeight + " kg\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } // BMI if (sWeight.length() > 0 && sHeight.length() > 0) { try { DecimalFormat deci = new DecimalFormat("0.0"); Float bmi = new Float(Float.parseFloat(sWeight.replaceAll(",", ".")) * 10000 / (Float.parseFloat(sHeight.replaceAll(",", ".")) * Float.parseFloat(sHeight.replaceAll(",", ".")))); par.add(new Chunk("BMI: " + deci.format(bmi), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } catch (Exception e) { e.printStackTrace(); } } } cell = new PdfPCell(par); cell.setColspan(3); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 2 : Urineonderzoek par = new Paragraph("URINE\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); tran = sessionContainerWO.getLastTransactionTypeUrineExamination(); if (tran != null) { item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_ALBUMINE"); if (item != null) { par.add(new Chunk("Albumine: " + getTran("Web.Occup", item.getValue()) + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_GLUCOSE"); if (item != null) { par.add(new Chunk("Glucose: " + getTran("Web.Occup", item.getValue()) + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_BLOOD"); if (item != null) { par.add(new Chunk( getTran("Web.Occup", "medwan.common.blood") + ": " + getTran("Web.Occup", item.getValue()), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } } cell = new PdfPCell(par); cell.setColspan(3); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 2 : Audiometrie par = new Paragraph(getTran("Web.Occup", "medwan.common.audiometry").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); tran = sessionContainerWO.getLastTransactionTypeAudiometry(); if (tran != null) { par.add(new Chunk(getTran("Web.Occup", "medwan.common.mean-hearing-loss").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_RIGHT_LOSS"); if (item != null) { par.add(new Chunk( getTran("Web.Occup", "medwan.common.right") + ": -" + item.getValue() + " dB\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_LEFT_LOSS"); if (item != null) { par.add(new Chunk( getTran("Web.Occup", "medwan.common.left") + ": -" + item.getValue() + " dB\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } } cell = new PdfPCell(par); cell.setColspan(3); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 2 : Visus par = new Paragraph( getTran("Web.Occup", "medwan.common.vision").toUpperCase() + " - " + getTran("Web.Occup", IConstants_PREFIX + "item_type_opthalmology_screen_visiotest_vision_far") .toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); tran = sessionContainerWO.getLastTransactionTypeOphtalmology(); if (tran != null) { par.add(new Chunk(getTran("Web.Occup", "medwan.common.right-left-binocular").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC))); par.add(new Chunk(getTran("Web.Occup", "medwan.common.without-correction") + ": ", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITHOUT_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITHOUT_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITHOUT_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("\n" + getTran("Web.Occup", "medwan.common.with-correction") + ": ", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITH_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITH_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITH_GLASSES"); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } } cell = new PdfPCell(par); cell.setColspan(3); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); // row 2 : Bloeddruk par = new Paragraph(getTran("Web.Occup", "medwan.common.blood-pressure").toUpperCase() + "\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)); tran = sessionContainerWO.getLastTransactionTypeGeneralClinicalExamination(); if (tran != null) { // right ItemVO item1 = tran.getItem( IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_RIGHT"); item = tran.getItem( IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_RIGHT"); if (item1 != null || item != null) { par.add(new Chunk(getTran("Web.Occup", "medwan.common.right") + ": ", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); if (item1 != null) { par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } // left item = tran.getItem( IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_LEFT"); item1 = tran.getItem( IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_LEFT"); if (item != null || item1 != null) { par.add(new Chunk(getTran("Web.Occup", "medwan.common.left") + ": ", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); if (item != null) { par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); if (item1 != null) { par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD))); } } cell = new PdfPCell(par); cell.setColspan(3); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(cell); doc.add(table); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java
protected void printAdminHeader(AdminPerson activePerson) { try {// w ww . j a va 2s . co m doc.add(new Paragraph(" ")); table = new PdfPTable(4); table.setWidthPercentage(100); // title cell = new PdfPCell( new Paragraph(getTran("Web.Occup", "medwan.common.administrative-data").toUpperCase(), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC))); cell.setColspan(4); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(cell); // firstname cell = new PdfPCell(new Paragraph(activePerson.firstname + " " + activePerson.lastname, FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); cell.setColspan(2); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); table.addCell(cell); // dateOfBirth cell = new PdfPCell(new Paragraph("" + activePerson.dateOfBirth, FontFactory.getFont( FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); cell.setColspan(1); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); table.addCell(cell); // gender cell = new PdfPCell(new Paragraph(activePerson.gender + "", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD))); cell.setColspan(1); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); table.addCell(cell); // address AdminPrivateContact contact = activePerson.getActivePrivate(); if (contact != null) { cell = new PdfPCell(new Paragraph( contact.district + " - " + ScreenHelper.getTran(null, "province", contact.province, sPrintLanguage), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.NORMAL))); cell.setColspan(4); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(BaseColor.LIGHT_GRAY); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); table.addCell(cell); } doc.add(table); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.mxs.common.util.pdf.general.oc.examinations.PDFDrivingLicenseDeclaration.java
private PdfPTable addQuestion(PdfPTable table, int id, String question, String answer) { // cel 1 : nr cell = new PdfPCell(new Phrase(id + "", FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); cell.setColspan(1);/*from ww w . j a va 2 s . c o m*/ cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); table.addCell(cell); // cel 2-38 : question cell = new PdfPCell(new Phrase(question, FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); cell.setColspan(37); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); table.addCell(cell); // cel 39 and 40 : answer cell = new PdfPCell(new Phrase(getTran(getItemValue(answer)), FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL))); cell.setColspan(2); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); table.addCell(cell); return table; }
From source file:bestdeal.util.genererPdf.java
public static void main(String[] args) { // - Paramtres de connexion la base de donnes Connection connection;//w w w.ja v a2s . co m String[][] data = new String[][] { { " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " " }, }; try { String requete = "select c.nom,c.prenom,c.email,k.nom,k.prenom,k.telephone,k.adresse,k.email,d.id_deal,d.nom_deal,v.quantite,v.prix_unitaire from client c INNER JOIN voucher v on v.id_client=c.id_client INNER JOIN deal d on v.id_deal=d.id_deal INNER JOIN vendeur k on d.id_vendeur=k.id_vendeur"; connection = MyConnection.getInstance(); mypdf = new Document(PageSize.A4, 50, 50, 50, 50); File di = new File("C:/Voucher"); File fl[] = di.listFiles(); try { OutputStream file = new FileOutputStream(new File("C:/Voucher\\Voucher.pdf")); PdfWriter.getInstance(mypdf, file); mypdf.open(); Statement stm; mypdf.addAuthor("Best Deal"); mypdf.addSubject("Voucher "); mypdf.add(new Paragraph("Socite BestDeal")); mypdf.add(new Paragraph("Adresse La Chotrana ESPRIT ")); mypdf.add(new Paragraph("TEL : xx xxx xxx")); mypdf.add(new Paragraph("FAX : xx xxx xxx")); mypdf.add(new Paragraph( " " + new Date().toString())); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" " + "Voucher N'01", FontFactory.getFont(FontFactory.HELVETICA, 21, Font.BOLDITALIC))); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph("CLIENT :", FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC))); try { stm = connection.createStatement(); ResultSet rs = stm.executeQuery(requete); while (rs.next()) { // add a country to the document as a Chunk //mypdf.add(new Chunk(rs.getString("quantite"))); Phrase p = new Phrase("Nom: "); Phrase p2 = new Phrase(new Chunk(rs.getString("nom"))); Paragraph pa = new Paragraph(); pa.add(p); pa.add(p2); mypdf.add(pa); Phrase p3 = new Phrase("Prenom: "); Phrase p4 = new Phrase(new Chunk(rs.getString("prenom"))); Paragraph pa1 = new Paragraph(); pa1.add(p3); pa1.add(p4); mypdf.add(pa1); Phrase p5 = new Phrase("Adresse: "); Phrase p6 = new Phrase(new Chunk(rs.getString("adresse"))); Paragraph pa2 = new Paragraph(); pa2.add(p5); pa2.add(p6); mypdf.add(pa2); Phrase p7 = new Phrase("Tlphone: "); Phrase p8 = new Phrase(new Chunk(rs.getString("telephone"))); Paragraph pa3 = new Paragraph(); pa3.add(p7); pa3.add(p8); mypdf.add(pa3); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph("Vendeur :", FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC))); Phrase p9 = new Phrase("Nom: "); Phrase p10 = new Phrase(new Chunk(rs.getString("nom"))); Paragraph pa4 = new Paragraph(); pa4.add(p9); pa4.add(p10); mypdf.add(pa4); Phrase p11 = new Phrase("Prnom: "); Phrase p12 = new Phrase(new Chunk(rs.getString("prenom"))); Paragraph pa5 = new Paragraph(); pa5.add(p11); pa5.add(p12); mypdf.add(pa5); Phrase p13 = new Phrase("Tlphone: "); Phrase p14 = new Phrase(new Chunk(rs.getString("telephone"))); Paragraph pa6 = new Paragraph(); pa6.add(p13); pa6.add(p14); mypdf.add(pa6); Phrase p15 = new Phrase("Adresse: "); Phrase p16 = new Phrase(new Chunk(rs.getString("adresse"))); Paragraph pa7 = new Paragraph(); pa7.add(p15); pa7.add(p16); mypdf.add(pa7); Phrase p17 = new Phrase("Email: "); Phrase p18 = new Phrase(new Chunk(rs.getString("email"))); Paragraph pa8 = new Paragraph(); pa8.add(p17); pa8.add(p18); mypdf.add(pa8); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); for (int i = 0; i < rs.getRow(); i++) { for (int j = 0; j < data[i].length - 1; j++) { data[i][j] = rs.getString(j + 9); // if (j==3) // data[i][4]= Float.parseFloat(data[i][3])*Integer.parseInt(data[i][2])+""; } } for (int i = 0; i < rs.getRow(); i++) { float s = Integer.parseInt(data[i][2].trim()) * Float.parseFloat(data[i][3].trim()); data[i][4] = s + ""; } //mypdf.add(new Phrase("nom")); //mypdf.add(new Chunk(rs.getString("nom"))); //mypdf.add( new Paragraph("nom:", new Chunk(rs.getString("nom")))); //mypdf.add(new Chunk(" ")); //Chunk id = new Chunk(rs.getString("id")); // with a background color //id.setBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f); // and a text rise //id.setTextRise(6); // mypdf.add(id); mypdf.add(Chunk.NEWLINE); } } catch (SQLException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } // mypdf.add(new Paragraph("Nom ")); // mypdf.add(new Paragraph("Prenom ")); // mypdf.add(new Paragraph("Adresse ")); //mypdf.add(new Paragraph("Tlphone ")); // mypdf.add(new Paragraph("Nom ")); // mypdf.add(new Paragraph("Nom de la socit ")); // mypdf.add(new Paragraph("Adresse ")); // mypdf.add(new Paragraph("Tlphone ")); // mypdf.add(new Paragraph(" ")); String[] headers = new String[] { " Id_deal", " Nom Deal", " Quantit", " Prix unitaire", " Prix total" }; PdfPTable table = new PdfPTable(headers.length); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setGrayFill(0.9f); cell.setPhrase(new Phrase(header.toUpperCase())); table.addCell(cell); } table.completeRow(); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { String datum = data[i][j]; PdfPCell cell = new PdfPCell(); cell.setPhrase(new Phrase(datum.toUpperCase())); table.addCell(cell); } table.completeRow(); } mypdf.add(table); } catch (FileNotFoundException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph( "Pour toute question concernant cette facture,veuillez contacter Nom,numro de tlphone,adresse de messagerie ", FontFactory.getFont(null, 9, Font.NORMAL))); mypdf.add(new Paragraph( " Merci pour votre confiance", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLDITALIC))); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.add(new Paragraph(" ")); mypdf.close(); } catch (DocumentException ex) { Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:billerfx.FXMLBillController.java
File generatePDF() { File fi = null;//from w ww .j a v a 2 s . c o m try { Stage gg = ((Stage) imv.getParent().getScene().getWindow()); fi = File.createTempFile("billerfx_" + gg.getTitle(), ".pdf"); fi.deleteOnExit(); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(fi)); Rectangle r = new RectangleReadOnly(207, 575); document.setPageSize(r); document.setMargins(15, 15, 0, 0); document.open(); Font fontbold = FontFactory.getFont("Times-Roman", 10, Font.NORMAL); Font fontbold2 = FontFactory.getFont("Times-Roman", 9, Font.NORMAL); String[] ll = Database.getCurrentSettings(); String ss = "-----------------------------------------------------\n"; ss += ll[0] + "\nAddress: " + ll[1] + "\nPhone: " + ll[2] + "\n"; String kk = Calendar.getInstance().get(Calendar.AM_PM) == Calendar.AM ? "AM" : (Calendar.getInstance().get(Calendar.AM_PM) == Calendar.PM ? "PM" : ""); ss += Calendar.getInstance().get(Calendar.DATE) + "/" + (1 + Calendar.getInstance().get(Calendar.MONTH)) + "/" + Calendar.getInstance().get(Calendar.YEAR) + " at " + Calendar.getInstance().get(Calendar.HOUR) + ":" + Calendar.getInstance().get(Calendar.MINUTE) + " " + kk + "\n"; ss += "Table No. " + c.getText() + " Bill No. " + a.getText() + "\n"; ss += "-----------------------------------------------------\n"; Paragraph para = new Paragraph(ss, fontbold); para.setAlignment(Paragraph.ALIGN_CENTER); document.add(para); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); float[] columnWidths = { 3f, 1f }; table.setWidths(columnWidths); PdfPCell defaultCell = table.getDefaultCell(); defaultCell.setBorder(PdfPCell.NO_BORDER); ObservableList ob = map.get(Integer.parseInt(gg.getTitle())); for (int i = 0; i < ob.size(); i++) { Item2 ii = (Item2) ob.get(i); String s1 = ii.getQuantity() + " x " + ii.getName(); String s2 = "Rs. " + ii.getTotal(); Paragraph para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); Paragraph para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); PdfPCell cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); PdfPCell cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); } document.add(table); para = new Paragraph("-----------------------------------------------------\n", fontbold); para.setAlignment(Paragraph.ALIGN_CENTER); document.add(para); table = new PdfPTable(2); table.setWidthPercentage(100); table.setWidths(columnWidths); defaultCell = table.getDefaultCell(); defaultCell.setBorder(PdfPCell.NO_BORDER); String s1 = "Total:"; String s2 = "Rs. " + h.getText(); Paragraph para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); Paragraph para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); PdfPCell cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); PdfPCell cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); if (Double.parseDouble(h.getText()) - Double.parseDouble(i.getText()) > 0.0) { s1 = "Discount:"; s2 = "Rs. " + BillerFX.df.format(Double.parseDouble(h.getText()) - Double.parseDouble(i.getText())); para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); } if (ll[7].equals("1")) { s1 = ll[3]; s2 = "Rs. " + k.getText(); para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); } if (ll[8].equals("1")) { s1 = ll[4]; s2 = "Rs. " + l.getText(); para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); } s1 = "Grand Total:"; s2 = "Rs. " + m.getText(); para1 = new Paragraph(s1, fontbold2); para1.setAlignment(Paragraph.ALIGN_LEFT); para2 = new Paragraph(s2, fontbold2); para2.setAlignment(Paragraph.ALIGN_RIGHT); cell1 = new PdfPCell(para1); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell2 = new PdfPCell(para2); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(cell2); document.add(table); para = new Paragraph("-----------------------------------------------------\n", fontbold); para.setAlignment(Paragraph.ALIGN_CENTER); document.add(para); fontbold2 = FontFactory.getFont("Times-Roman", 8, Font.NORMAL); para = new Paragraph( "Thank You.\nThis invoice was created using BillerFX.\n (BillerFX Contact: ayushmaanbhav1008@gmail.com)\n", fontbold2); para.setAlignment(Paragraph.ALIGN_CENTER); document.add(para); para = new Paragraph("-----------------------------------------------------\n", fontbold); para.setAlignment(Paragraph.ALIGN_CENTER); document.add(para); document.close(); } catch (Exception mm) { } return fi; }
From source file:br.com.tcc.relat.BalancoAnual.java
public static void main(String[] args) throws Exception { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ ResultSet query = stmt.executeQuery( "SELECT produto.ID, produto.descricao, produto.numEstoque, produto.numEstoqueCritico, unidade.descricao, fornecedor.nome FROM produto as produto INNER JOIN unidade as unidade ON (produto.idUnidade = unidade.id) INNER JOIN fornecedor as fornecedor ON (produto.idFornecedor = fornecedor.id)"); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); //PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Balanco.pdf")); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../RelatBalanco.pdf")); PDFLogReport.open();/*from w ww .j a v a 2 s . co m*/ Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(6); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Balano Anual"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(6); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Fornecedor", fonte)); LogTable.addCell(new Paragraph("Unidade", fonte)); LogTable.addCell(new Paragraph("Estoque", fonte)); LogTable.addCell(new Paragraph("Estoque Crtico", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String fornecedor = query.getString("nome"); LogTable.addCell(new Paragraph(fornecedor, fonteDados)); String unidade = query.getString("unidade.descricao"); LogTable.addCell(new Paragraph(unidade, fonteDados)); String estoque = query.getString("numEstoque"); LogTable.addCell(new Paragraph(estoque, fonteDados)); String critico = query.getString("numEstoqueCritico"); LogTable.addCell(new Paragraph(critico, fonteDados)); LogTable.addCell(new Paragraph(" ", fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Balanco.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../RelatBalanco.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }
From source file:br.com.tcc.relat.ConsultarVendas.java
public void relat(String sql) throws SQLException, DocumentException, FileNotFoundException, IOException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../VendaDoDia.pdf")); PDFLogReport.open();/*from w w w . ja v a2s . c om*/ Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(9); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio Venda do Dia"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(9); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Cliente ", fonte)); LogTable.addCell(new Paragraph("Funcionario", fonte)); LogTable.addCell(new Paragraph("Tipo Pagamento", fonte)); LogTable.addCell(new Paragraph("Data Compra", fonte)); LogTable.addCell(new Paragraph("Valor Sugerido", fonte)); LogTable.addCell(new Paragraph("Valor da Venda", fonte)); LogTable.addCell(new Paragraph("Parcelas", fonte)); LogTable.addCell(new Paragraph("1 Vencimento", fonte)); LogTable.addCell(new Paragraph("Status da Compra", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String cliente = query.getString("cliente.nome"); LogTable.addCell(new Paragraph(cliente, fonteDados)); String funcionario = query.getString("funcionario.nome"); LogTable.addCell(new Paragraph(funcionario, fonteDados)); String tipoPagamento = query.getString("tipopagamento.descricao"); LogTable.addCell(new Paragraph(tipoPagamento, fonteDados)); String dataVenda = query.getString("dataVenda"); LogTable.addCell(new Paragraph(dataVenda, fonteDados)); String vlrSugerido = query.getString("vlrSugerido"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String totalVenda = query.getString("totalVenda"); LogTable.addCell(new Paragraph(totalVenda, fonteDados)); String parcela = query.getString("parcela"); LogTable.addCell(new Paragraph(parcela, fonteDados)); String vencimento = query.getString("1vencimento"); LogTable.addCell(new Paragraph(vencimento, fonteDados)); String ativo = query.getString("ativo"); LogTable.addCell(new Paragraph(ativo, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\VendaDoDia.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../VendaDoDia.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }
From source file:br.com.tcc.relat.ProdutosRelat.java
public static void main(String[] args) throws Exception { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ ResultSet query = stmt.executeQuery( "SELECT produto.ID, produto.descricao, produto.vlrCompra, produto.vlrVenda, produto.numEstoque, produto.numEstoqueCritico, unidade.descricao, fornecedor.nome FROM produto as produto INNER JOIN unidade as unidade ON (produto.idUnidade = unidade.id) INNER JOIN fornecedor as fornecedor ON (produto.idFornecedor = fornecedor.id)"); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../TesteProdutos.pdf")); PDFLogReport.open();/*from www. j a v a 2 s . c o m*/ Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(7); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio de Produtos"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(7); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Fornecedor", fonte)); LogTable.addCell(new Paragraph("Unidade", fonte)); LogTable.addCell(new Paragraph("Valor Compra", fonte)); LogTable.addCell(new Paragraph("Valor Venda", fonte)); LogTable.addCell(new Paragraph("Estoque", fonte)); LogTable.addCell(new Paragraph("Estoque Crtico", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String fornecedor = query.getString("nome"); LogTable.addCell(new Paragraph(fornecedor, fonteDados)); String unidade = query.getString("unidade.descricao"); LogTable.addCell(new Paragraph(unidade, fonteDados)); String compra = query.getString("vlrCompra"); LogTable.addCell(new Paragraph(compra, fonteDados)); String venda = query.getString("vlrVenda"); LogTable.addCell(new Paragraph(venda, fonteDados)); String estoque = query.getString("numEstoque"); LogTable.addCell(new Paragraph(estoque, fonteDados)); String critico = query.getString("numEstoqueCritico"); LogTable.addCell(new Paragraph(critico, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\TesteProdutos.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../TesteProdutos.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }
From source file:br.com.tcc.relat.VendasDoAno.java
public static void main(String[] args) throws Exception { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ ResultSet query = stmt.executeQuery( "SELECT YEAR(dataVenda) as ano, SUM(totalVenda) as total FROM vendaregistro GROUP BY ano"); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../VendaDoAno.pdf")); PDFLogReport.open();/*from w ww . ja v a2s . c om*/ Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(2); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio Anual"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(2); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Ano ", fonte)); LogTable.addCell(new Paragraph("Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String ano = query.getString("ano"); LogTable.addCell(new Paragraph(ano, fonteDados)); String total = query.getString("total"); LogTable.addCell(new Paragraph(total, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\VendaDoAno.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../VendaDoAno.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }
From source file:br.com.tcc.relat.VendasDoDia.java
public static void main(String[] args) throws Exception { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); /* Define the SQL query */ ResultSet query = stmt.executeQuery( "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + "INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("../../VendaDoDia.pdf")); PDFLogReport.open();/* w w w .j ava2 s .c o m*/ Paragraph cabecalho = new Paragraph( "AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n\n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(9); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio Venda do Dia"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(9); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Cliente ", fonte)); LogTable.addCell(new Paragraph("Funcionario", fonte)); LogTable.addCell(new Paragraph("Tipo Pagamento", fonte)); LogTable.addCell(new Paragraph("Data Compra", fonte)); LogTable.addCell(new Paragraph("Valor Sugerido", fonte)); LogTable.addCell(new Paragraph("Valor da Venda", fonte)); LogTable.addCell(new Paragraph("Parcelas", fonte)); LogTable.addCell(new Paragraph("1 Vencimento", fonte)); LogTable.addCell(new Paragraph("Status da Compra", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String cliente = query.getString("cliente.nome"); LogTable.addCell(new Paragraph(cliente, fonteDados)); String funcionario = query.getString("funcionario.nome"); LogTable.addCell(new Paragraph(funcionario, fonteDados)); String tipoPagamento = query.getString("tipopagamento.descricao"); LogTable.addCell(new Paragraph(tipoPagamento, fonteDados)); String dataVenda = query.getString("dataVenda"); LogTable.addCell(new Paragraph(dataVenda, fonteDados)); String vlrSugerido = query.getString("vlrSugerido"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String totalVenda = query.getString("totalVenda"); LogTable.addCell(new Paragraph(totalVenda, fonteDados)); String parcela = query.getString("parcela"); LogTable.addCell(new Paragraph(parcela, fonteDados)); String vencimento = query.getString("1vencimento"); LogTable.addCell(new Paragraph(vencimento, fonteDados)); String ativo = query.getString("ativo"); LogTable.addCell(new Paragraph(ativo, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\VendaDoDia.pdf"; //Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); File pdf = new File("../../VendaDoDia.pdf"); try { Desktop.getDesktop().open(pdf); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, "Erro ao abrir relatrio: " + ex); } }