List of usage examples for com.itextpdf.text BaseColor WHITE
BaseColor WHITE
To view the source code for com.itextpdf.text BaseColor WHITE.
Click Source Link
From source file:com.jpsycn.print.util.PDFUtils.java
/** * ?????//from ww w.ja v a 2 s. co m * * @param mContext * @param file * ?pdf * @param map * ??? * @return */ public static boolean createSamplingPdf(Context mContext, File file, Map<String, String> map) { try { Font simfang12 = FontUtil.getFont(mContext, 12, "simfang.ttf"); Font bf = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.BOLD, null); Document document = setHeader(file, mContext, simfang12, bf, "?????", map.get("sno") == null ? " " : map.get("sno")); // ?100 int cols = 100; // ????5 // ?5 // ?5? int m = 7; int n = 28; int o = 27; int p = 10; int q = 28; PdfPTable table1 = new PdfPTable(cols); // ???80%100% table1.setWidthPercentage(100); table1.setSpacingBefore(3f); table1.addCell(ItextUtil.getCell(simfang12, "?", m + n)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked( new String[] { "", "", "???", "??", "??", "" }, map.get("sample_type")), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "", m + n)); table1.addCell( ItextUtil.getCell(simfang12, ItextUtil.checked( new String[] { "", "", "???", "", "??", "", "?", "", "" }, map.get("sampling_address")), o + p + q, false)); table1.addCell(ItextUtil.getCell(simfang12, "", m, 3)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("name"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", n)); table1.addCell(ItextUtil.getCell(bf, map.get("address"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("contact_and_phone"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", m, 8)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_name"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_type"), o)); table1.addCell(ItextUtil.getCell(simfang12, "?", p)); table1.addCell(ItextUtil.getCell(bf, map.get("product_level"), q)); table1.addCell(ItextUtil.getCell(simfang12, "", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_brand"), o)); table1.addCell(ItextUtil.getCell(simfang12, "", p)); table1.addCell(ItextUtil.getCell(bf, map.get("product_standard"), q)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_sno"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "/?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_date"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("product_expired"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("number"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "", n)); table1.addCell(ItextUtil.getCell(bf, map.get("date"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "???" + ItextUtil.checked(new String[] { "", "?" }, map.get("company_equal_sampling_ground")) + "????", cols)); table1.addCell(ItextUtil.getCell(simfang12, "?", m, 3)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_name"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_address"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_linkman_and_phone"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "", m, 4)); table1.addCell(ItextUtil.getCell(simfang12, "??", n)); table1.addCell(ItextUtil.getCell(bf, map.get("depart_name"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("depart_people"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", n)); table1.addCell(ItextUtil.getCell(bf, map.get("depart_phone"), o + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "/Email", n)); table1.addCell(ItextUtil.getCell(bf, map.get("depart_email"), o + p + q)); // ? Font blackFont = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.NORMAL, BaseColor.WHITE); String remark = map.get("remark") == null ? "" : map.get("remark"); int nn = 25 + 43 * 6; if (remark != null && remark.length() < 25 + 43 * 4) { nn = nn - remark.length(); } table1.addCell(ItextUtil.getRemarkCell(simfang12, blackFont, "?", bf, remark, cols, nn)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "??", "?", " ", 35, 7, 6 + 14 * 4 + 14)); table1.addCell(ItextUtil.getMultiCell2(simfang12, blackFont, "", " ", 33, 5 + 14 * 5 + 9)); table1.addCell(ItextUtil.getMultiCell2(simfang12, blackFont, "??", " ", 32, 5 + 13 * 5 + 8)); document.add(table1); Font simfang8 = FontUtil.getFont(mContext, 8, "simfang.ttf"); Paragraph r1 = new Paragraph( ":1.?,???,????", simfang8); document.add(r1); Paragraph r2 = new Paragraph( "2.???3.????", simfang8); document.add(r2); zxing(map.get("zxing"), mContext, document); stmp(mContext, document, 220, 40); Paragraph bbb = new Paragraph(ItextUtil.getBlackStr(88), blackFont); document.add(bbb); // document.close(); return true; } catch (Exception e) { Log.e(TAG, "", e); return false; } }
From source file:com.jpsycn.print.util.PDFUtils.java
/** * ???/??//from w w w . jav a2 s . com * * @param mContext * @param file * @param map * @return */ public static boolean createReSamplePdf(Context mContext, File file, Map<String, String> map) { try { Font simfang12 = FontUtil.getFont(mContext, 12, "simfang.ttf"); Font bf = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.BOLD, null); Document document = setHeader(file, mContext, simfang12, bf, "???/??", map.get("sno") == null ? " " : map.get("sno")); // int cols = 100; int m = 5; int n = 12; int o1 = 11; int o2 = 11; int o3 = 11; int p = 5; int q = 5; int r = 20; int s = 20; int o = o1 + o2 + o3; PdfPTable table1 = new PdfPTable(cols); // ???80%100% table1.setWidthPercentage(100); table1.setSpacingBefore(3f); table1.addCell(ItextUtil.getCell(simfang12, "??", m + n)); table1.addCell(ItextUtil.getCell(bf, map.get("source"), o)); table1.addCell(ItextUtil.getCell(simfang12, "", p + q)); table1.addCell(ItextUtil.getCell(bf, map.get("check_type"), r + s)); table1.addCell(ItextUtil.getCell(simfang12, "???", m, 3, false, true)); table1.addCell(ItextUtil.getCell(simfang12, " ??? ?", n, 3, false, true)); table1.addCell(ItextUtil.getCell(bf, map.get("name"), o)); table1.addCell(ItextUtil.getCell(simfang12, "", p + q)); table1.addCell(ItextUtil.getCell(bf, map.get("legal_representative"), r + s)); table1.addCell(ItextUtil.getCell(bf, map.get("address"), o)); table1.addCell(ItextUtil.getCell(simfang12, "? ??", p + q, 2, false, true)); table1.addCell(ItextUtil.getCell(bf, map.get("contact_and_phone"), r + s, 2)); table1.addCell(ItextUtil.getCell(simfang12, "", o)); table1.addCell(ItextUtil.getCell(simfang12, "??", m, 10, false, true)); table1.addCell(ItextUtil.getCell(simfang12, "????", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_name"), o)); table1.addCell(ItextUtil.getCell(simfang12, "?", p, 10, false, true)); String companyType = map.get("company_type"); table1.addCell(ItextUtil.getCell(simfang12, "", q, 4, false, true)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("", companyType), r)); table1.addCell( ItextUtil.getCell(simfang12, ItextUtil.checked("???", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_address"), o)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("", companyType), r)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("??", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_zip"), o)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("??", companyType), r)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("??", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_legal_representative"), o)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("?", companyType), r)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("?", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_linkman"), o)); table1.addCell(ItextUtil.getCell(simfang12, "?", q, 3, false, true)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("???", companyType), r)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("???", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "??", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_phone"), o)); table1.addCell( ItextUtil.getCell(simfang12, ItextUtil.checked("???", companyType), r, 2)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("??", companyType), s, 2)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_license"), o)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("company_code"), o)); table1.addCell(ItextUtil.getCell(simfang12, "", q, 3, false, true)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("?", companyType), r)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("?", companyType), s)); table1.addCell(ItextUtil.getCell(simfang12, "?", n, 2)); table1.addCell(ItextUtil.getCell(simfang12, "", o1, false)); table1.addCell(ItextUtil.getCell(simfang12, "", o2)); table1.addCell(ItextUtil.getCell(simfang12, "?", o3)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("?", companyType), r, 2)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked("??", companyType), s, 2)); table1.addCell(ItextUtil.getCell(bf, map.get("company_person_number"), o1)); table1.addCell(ItextUtil.getCell(bf, map.get("company_output_value"), o2)); table1.addCell(ItextUtil.getCell(bf, map.get("company_production"), o3)); table1.addCell(ItextUtil.getCell(simfang12, "???", m, 8, false, true)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked(new String[] { "???", "QS", "CCC", "" }, map.get("product_certificate_type")), n + o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", r)); table1.addCell(ItextUtil.getCell(bf, map.get("product_certificate_sno"), s)); table1.addCell(ItextUtil.getCell(simfang12, "???", n + o1)); table1.addCell(ItextUtil.getCell(bf, map.get("product_name"), o2 + o3)); table1.addCell(ItextUtil.getCell(simfang12, "?", p + q + r)); table1.addCell(ItextUtil.getCell(bf, map.get("product_type"), s)); table1.addCell(ItextUtil.getCell(simfang12, "/?", n + o1)); table1.addCell(ItextUtil.getCell(bf, map.get("product_date"), o2 + o3)); table1.addCell(ItextUtil.getCell(simfang12, "", p + q + r)); table1.addCell(ItextUtil.getCell(bf, map.get("product_brand"), s)); // gg(map, simfang12, bf, table1); // table1.addCell(ItextUtil.getCell(simfang12, "", n + o1)); table1.addCell(ItextUtil.getCell(bf, map.get("samplint_date"), o2 + o3)); table1.addCell(ItextUtil.getCell(simfang12, "??", p + q + r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_state"), s)); table1.addCell(ItextUtil.getCell(simfang12, "???", n + o1)); table1.addCell(ItextUtil.getCell(bf, map.get("samplint_volumn_and_storage_address"), o2 + o3)); table1.addCell(ItextUtil.getCell(simfang12, "?", p + q + r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_send_address"), s)); table1.addCell(ItextUtil.getCell(simfang12, "???", n + o1)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked(new String[] { "", "?" }, map.get("is_export_product")), o2 + o3)); table1.addCell(ItextUtil.getCell(simfang12, "?", p + q + r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_send_expired"), s)); table1.addCell(ItextUtil.getCell(simfang12, "??", m, 3, false, true)); table1.addCell(ItextUtil.getCell(simfang12, "????", n)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_name"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "?", r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_people"), s)); table1.addCell(ItextUtil.getCell(simfang12, "???", n)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_address"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_phone"), s)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_zip"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "/Email", r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_email"), s)); Font blackFont = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.NORMAL, BaseColor.WHITE); String remark = map.get("remark") == null ? "" : map.get("remark"); int nn = 30 + 43 * 3; if (remark != null && remark.length() < 25 + 43 * 4) { nn = nn - remark.length(); } table1.addCell(ItextUtil.getRemarkCell(simfang12, blackFont, "?", bf, remark, cols, nn)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "???", "?????", " ", 32, 1, 2 + 13 * 2 + 6)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "??", "????", " ", 32, 1, 2 + 13 * 2 + 6)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "??", "??", " ", 36, 7 + 15 * 2 + 6, 9)); document.add(table1); Font simfang8 = FontUtil.getFont(mContext, 8, "simfang.ttf"); Paragraph r1 = new Paragraph( "1.??????", simfang8); document.add(r1); Paragraph r2 = new Paragraph( "2.???QS?CCC???3.???????", simfang8); document.add(r2); zxing(map.get("zxing"), mContext, document); stmp(mContext, document, 380, 40); Paragraph bbb = new Paragraph(ItextUtil.getBlackStr(44), blackFont); document.add(bbb); // 5: document.close(); return true; } catch (Exception e) { Log.e(TAG, "", e); return false; } }
From source file:com.jpsycn.print.util.PDFUtils.java
/** * ????/??/* w ww . ja v a 2 s .c o m*/ * * @param mContext * @param file * @param map * @return */ public static boolean createSpaqPdf(Context mContext, File file, Map<String, String> map) { try { /* * String[] ss = new String[] { "",".", "", "", "?", "?", "", * "", "", "",".", "", "", "?", "?", "", "", "", "",".", * "", "", "", "", "", "", "", "", "", "", ".","", "", * "", "?", "", "", "?", "", "?", "", "", "?", "", "", "", * "?", "", "", "", "", "" }; */ /* * PdfContentByte cb = writer.getDirectContent(); BaseFont simfang = * FontUtil.getBaseFont(mContext, "simfang.ttf"); cb.beginText(); * cb.setFontAndSize(simfang, 12); float w = 595 - 30; for (int i = * 0; i < ss.length; i++) { String temp = ss[i]; if * (temp.equals("") || temp.equals("")) { * cb.showTextAligned(PdfContentByte.ALIGN_CENTER, temp, w+2, * (680f-i*10)+3, 270); } else { cb.setTextMatrix(w, 680f - i * 10); * cb.showText(temp); } } cb.endText(); */ Font simfang12 = FontUtil.getFont(mContext, 12, "simfang.ttf"); Font bf = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.BOLD, null); Document document = setHeader(file, mContext, simfang12, bf, "????/??", map.get("sno") == null ? " " : map.get("sno")); // int cols = 100; int m = 5; int n = 12; int o1 = 11; int o2 = 11; int o3 = 11; int p = 5; int q = 5; int r = 20; int s = 20; int o = o1 + o2 + o3; PdfPTable table1 = new PdfPTable(cols); // ???80%100% table1.setWidthPercentage(100); table1.setSpacingBefore(3f); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", m + n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("source"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", p + q)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("check_type"), r + s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", m, 3, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, "????", n, 3)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("name"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", p + q)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("legal_representative"), r + s)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("address"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", p + q, 2)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("contact_and_phone"), r + s, 2)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", m, 10, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, "????", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_name"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", p, 10, false, true)); String companyType = map.get("company_type"); table1.addCell(ItextUtil.getCell(simfang12, "", q, 4, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("", companyType), r)); table1.addCell( ItextUtil.getCell(20f, simfang12, ItextUtil.checked("???", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_address"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("", companyType), r)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("??", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_zip"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("??", companyType), r)); table1.addCell( ItextUtil.getCell(20f, simfang12, ItextUtil.checked("??", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_legal_representative"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("?", companyType), r)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("?", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_linkman"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", q, 3, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("???", companyType), r)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("???", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_phone"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("???", companyType), r, 2)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("??", companyType), s, 2)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_license"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("company_code"), o)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", q, 3)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("?", companyType), r)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("?", companyType), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n, 2)); StringBuilder sb3 = new StringBuilder(); sb3.append(""); sb3.append(map.get("company_person_number") == null ? " " : map.get("company_person_number")); sb3.append(" "); sb3.append(map.get("company_output_value") == null ? " " : map.get("company_output_value")); sb3.append(" ?"); sb3.append(map.get("company_production") == null ? " " : map.get("company_production")); // sb3.append("10000 5000 ?1000?"); Font simfang10 = FontUtil.getFont(mContext, 9, "simfang.ttf"); table1.addCell(ItextUtil.getCell(20f, simfang10, sb3.toString(), o1 + o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("?", companyType), r, 2)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked("??", companyType), s, 2)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked(new String[] { "", "", "?" }, map.get("company_scope")), o1 + o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", m, 9, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked(new String[] { "?", "??", "?", "??" }, map.get("food_type")), n + o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("product_certificate_sno"), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", n + o1)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("product_name"), o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", p + q + r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("product_type"), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "/?", n + o1)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("product_date"), o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", p + q + r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("product_brand"), s)); // gg(map, simfang12, bf, table1); // table1.addCell(ItextUtil.getCell(20f, simfang12, "", n + o1)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("samplint_date"), o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", p + q + r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_state"), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", n + o1)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("samplint_volumn_and_storage_address"), o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", p + q + r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_send_address"), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", n + o1)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_send_expired"), o2 + o3)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked(new String[] { "??", "???" }, map.get("is_famous_brand")), p + q + r + s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "", n)); table1.addCell(ItextUtil.getCell(20f, simfang12, ItextUtil.checked(new String[] { "???", "", "" }, map.get("sample_address_1")), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, ItextUtil.checked( new String[] { "", "?", "?" }, map.get("sample_address_2")), r + s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "??", m, 3, false, true)); table1.addCell(ItextUtil.getCell(20f, simfang12, "????", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_name"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(20f, simfang12, "?", r)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_people"), s)); table1.addCell(ItextUtil.getCell(20f, simfang12, "???", n)); table1.addCell(ItextUtil.getCell(20f, bf, map.get("sampling_address"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "??", r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_phone"), s)); table1.addCell(ItextUtil.getCell(simfang12, "?", n)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_zip"), o1 + o2 + o3 + p + q)); table1.addCell(ItextUtil.getCell(simfang12, "/Email", r)); table1.addCell(ItextUtil.getCell(bf, map.get("sampling_email"), s)); table1.addCell(ItextUtil.getCell(simfang12, "", m + n, 2)); StringBuilder sb = new StringBuilder(); sb.append("?"); sb.append(ItextUtil.checked(new String[] { "", "" }, map.get("sampling_result_1"))); sb.append("?"); sb.append(ItextUtil.checked(new String[] { "", "?" }, map.get("sampling_result_2"))); sb.append("\n"); sb.append("?"); sb.append(ItextUtil.checked(new String[] { "", "", "" }, map.get("sampling_result_3"))); sb.append("????"); sb.append(ItextUtil.checked(new String[] { "", "?" }, map.get("sampling_result_4"))); table1.addCell(ItextUtil.getCell(simfang12, sb.toString(), o1 + o2 + o3 + p + q + r + s, 2, false)); Font blackFont = FontUtil.getFont(mContext, 12, "simfang.ttf", Font.NORMAL, BaseColor.WHITE); table1.addCell(ItextUtil.getCell(simfang12, "", m + n, 2)); StringBuilder sb2 = new StringBuilder(); sb2.append("??"); sb2.append(ItextUtil.checked(new String[] { "", "" }, map.get("remark_1"))); sb2.append("\n"); sb2.append(""); // sb2.append(map.get("remark_2") == null ? "" : // map.get("remark_2")); String ss = map.get("remark_2") == null ? "" : map.get("remark_2"); table1.addCell(ItextUtil.getCell2(simfang12, sb2.toString(), bf, ss, o1 + o2 + o3 + p + q + r + s)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "???", "?????", " ", 32, 1, 2 + 13 * 2 + 6)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "??", "????", " ", 32, 1, 2 + 13 * 2 + 6)); table1.addCell(ItextUtil.getMultiCell3(simfang12, blackFont, "??", "??", " ", 36, 7 + 15 * 2 + 6, 9)); document.add(table1); Font simfang8 = FontUtil.getFont(mContext, 8, "simfang.ttf"); Paragraph r1 = new Paragraph( "1???4??????????????2??????????3????", simfang8); document.add(r1); zxing(map.get("zxing"), mContext, document); stmp(mContext, document, 380, 40); Paragraph bbb = new Paragraph(ItextUtil.getBlackStr(44), blackFont); document.add(bbb); // 5: document.close(); return true; } catch (Exception e) { Log.e(TAG, "", e); return false; } }
From source file:com.microware.intrahealth.Createpdf2.java
@SuppressLint("SdCardPath") public boolean write(Context context, String fname, String[] Header, ArrayList<HashMap<String, String>> data, String[] Page2, int Flag) throws Exception { try {// ww w .ja v a 2 s . c o m // file = new File(Environment.getExternalStorageDirectory()+IIHSPdf+ "/"+fname+".pdf"); this.context = context; g = (Global) context.getApplicationContext(); BaseFont urName = BaseFont.createFont("assets/FreeSans.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); urFontName = new Font(urName, 12); urName1 = FontFactory.getFont("assets/mangal.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // urFontName = new Font(urName, 12); sHeader[0] = context.getResources().getString(R.string.hrpreport); sHeader[1] = context.getResources().getString(R.string.anmname) + " " + g.getsGlobalANMName() + " " + context.getResources().getString(R.string.distname); sHeader[2] = context.getResources().getString(R.string.Identificationcode); sHeader2[0] = context.getResources().getString(R.string.Identificationcode1); sHeader2[1] = context.getResources().getString(R.string.totalhrp); sHeader2[2] = context.getResources().getString(R.string.totalcheckup); sHeader2[3] = context.getResources().getString(R.string.anmsign); catFont2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); if (Flag == 2) { catFont = new Font(urName, 16, Font.BOLD); catFont1 = new Font(urName, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(urName, 14); smallBold = new Font(urName, 12, Font.BOLD, BaseColor.WHITE); } else { catFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD); catFont1 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(Font.FontFamily.TIMES_ROMAN, 14); smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.WHITE); } String fpath = "/sdcard/msakhi/Pdf"; File path = new File(fpath); File file = new File(path, fname + ".pdf"); if (!path.exists()) { path.mkdirs(); if (!file.exists()) { file.createNewFile(); } } else { if (!file.exists()) { file.createNewFile(); } } // Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); // Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); Document document = new Document(A4.rotate()); PdfWriter.getInstance(document, new FileOutputStream(file.getAbsoluteFile())); document.open(); // addMetaData(document); // addTitlePage(document); addContent(document, Header, data, sHeader2, Flag); document.close(); return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } }
From source file:com.microware.intrahealth.Createpdfall.java
@SuppressLint("SdCardPath") public boolean write(String fname, String[] Header1, String[] Page1, String[] Page1Value, String heading1, String Page1Remark,//ww w .j av a 2 s . c o m String[] Header2, String[] Page2_1, String[] Page2_1source, String[] Page2_1value, String[] Page2_2, String[] Page2_2source, String[] Page2_2value, String[] Page2_3, String[] Page2_3source, String[] Page2_3value, String heading2, String heading3, String heading4, String heading5, String Remark2Value, String[] Header3, String[] Page31, String[] Page3Census1, String[] Page3Value1, String[] Page32, String[] Page3Census2, String[] Page3Value2, String heading6, String heading7, String heading8, String Page3Remark, String[] Header4, String[] Page4_1, String[] Page4Value1, String[] Page4_2, String[] Page4Value2, String[] Page4_3, String[] Page4Value3, String heading9, String heading10, String heading11, String heading12, String Page4Remark1, String Page4Remark3, String[] Header5, String[] Page5Value1, String[] Page5Value2, String[] Page5Value3, String[] Page5Value4, String[] Page5_2, String[] Page5Value5, String[] Page5_3, String[] Page5Value6, String text5, String value5, String heading13, String heading14, String heading15, String Page5Remark1, String Page5Remark2, String[] Header6, String[] Page6Value1, String[] Page6Value2, String[] Page6Value3, String[] Page6Value4, String text6, String value6, String heading16, String[] Header7_1, String[] Page7Value1, String[] Page7Value2, String[] Page7Value3, String[] Page7Value4, String[] Page7Value5, String[] Header7_2, String[] Page7Value6, String[] Page7Value7, String[] Page7Value8, String[] Page7Value9, String[] Page7Value10, String[] Page7Value11, String text7_1, String value7_1, String text7_2, String value7_2, String heading17, String heading18, String heading19, String pdf1, String pdf2, int Flag) throws Exception { try { // file = new File(Environment.getExternalStorageDirectory()+IIHSPdf+ "/"+fname+".pdf"); BaseFont urName = BaseFont.createFont("assets/baamini.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); urFontName = new Font(urName, 12); catFont2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); if (Flag == 2) { catFont = new Font(urName, 16, Font.BOLD); catFont1 = new Font(urName, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(urName, 14); smallBold = new Font(urName, 12, Font.BOLD, BaseColor.WHITE); } else { catFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD); catFont1 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(Font.FontFamily.TIMES_ROMAN, 14); smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.WHITE); } String fpath = "/sdcard/IIHS/Pdfs"; File path = new File(fpath); File file = new File(path, fname + ".pdf"); if (!path.exists()) { path.mkdirs(); if (!file.exists()) { file.createNewFile(); } } else { if (!file.exists()) { file.createNewFile(); } } // Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); // Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file.getAbsoluteFile())); document.open(); // addMetaData(document); // addTitlePage(document); addContent(document, Header1, Page1, Page1Value, heading1, Page1Remark, Header2, Page2_1, Page2_1source, Page2_1value, Page2_2, Page2_2source, Page2_2value, Page2_3, Page2_3source, Page2_3value, heading2, heading3, heading4, heading5, Remark2Value, Header3, Page31, Page3Census1, Page3Value1, Page32, Page3Census2, Page3Value2, heading6, heading7, heading8, Page3Remark, Header4, Page4_1, Page4Value1, Page4_2, Page4Value2, Page4_3, Page4Value3, heading9, heading10, heading11, heading12, Page4Remark1, Page4Remark3, Header5, Page5Value1, Page5Value2, Page5Value3, Page5Value4, Page5_2, Page5Value5, Page5_3, Page5Value6, text5, value5, heading13, heading14, heading15, Page5Remark1, Page5Remark2, Header6, Page6Value1, Page6Value2, Page6Value3, Page6Value4, text6, value6, heading16, Header7_1, Page7Value1, Page7Value2, Page7Value3, Page7Value4, Page7Value5, Header7_2, Page7Value6, Page7Value7, Page7Value8, Page7Value9, Page7Value10, Page7Value11, text7_1, value7_1, text7_2, value7_2, heading17, heading18, heading19, pdf1, pdf2, Flag); document.close(); return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfLavadasPendientes(Document doc, List<Lavada> lavadas) { Paragraph parrafo;/*from w ww . j ava 2 s . c o m*/ PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; JFreeChart chart; int w, h; int pos; pos = 0; w = h = 500; fuente = "arial"; if (lavadas.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Lavadas Pendientes"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); tabla = new PdfPTable(3); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Fecha", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Placa de Carro", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Modelo de Carro", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Cliente", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (Lavada lavada : lavadas) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(lavada.getId() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(lavada.getFechaLavado() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(lavada.getCarro().getPlaca()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(lavada.getCarro().getModelo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(lavada.getCarro().getCliente().getApellidos() + ", " + lavada.getCarro().getCliente().getNombres()); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(lavada.getId() + ""); tabla.addCell(lavada.getFechaLavado() + ""); tabla.addCell(lavada.getCarro().getPlaca()); tabla.addCell(lavada.getCarro().getModelo().getNombre()); tabla.addCell(lavada.getCarro().getCliente().getApellidos() + ", " + lavada.getCarro().getCliente().getNombres()); } i++; } doc.add(tabla); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfCliente(Document doc, Cliente cliente) { Paragraph parrafo;/*ww w .j a v a 2s. c o m*/ PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; fuente = "arial"; try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Cliente: " + cliente.getNombres(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); doc.add(Chunk.NEWLINE); txt = "Datos del Cliente"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 20, Font.UNDERLINE, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Id: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getId() + ""; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Nombres: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getNombres(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Apellidos: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getApellidos(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Dni: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getDni(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Email: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getEmail(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Telefono: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getTelefono(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Carros:"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); tabla = new PdfPTable(4); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Modelo", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Marca", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Placa", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (Carro carro : cliente.getCarros()) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(carro.getId() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(carro.getModelo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(carro.getMarca()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(carro.getPlaca()); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(carro.getId() + ""); tabla.addCell(carro.getModelo().getNombre()); tabla.addCell(carro.getMarca()); tabla.addCell(carro.getPlaca()); } i++; } doc.add(tabla); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfClienteCreditoDisponible(Document doc, List<CreditoDisponibleCliente> reporte) { Paragraph parrafo;//from www . ja va 2s. c o m PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; CreditoDisponibleCliente cliente; int i; fuente = "arial"; if (reporte.isEmpty()) { return; } cliente = reporte.get(0); try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Cliente: " + cliente.getNombres(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); doc.add(Chunk.NEWLINE); txt = "Crdito Disponible"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 20, Font.UNDERLINE, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Nombres: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getNombres(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Apellidos: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getApellidos(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Dni: "; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = cliente.getDni(); parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); txt = "Crdito Disponible:"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); doc.add(Chunk.NEWLINE); tabla = new PdfPTable(2); frase = new Phrase("Modelo", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Lavadas Disponibles", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (CreditoDisponibleCliente cre : reporte) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(cre.getModeloCarro()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(cre.getLavadas()); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(cre.getModeloCarro()); tabla.addCell(cre.getLavadas() + ""); } i++; } doc.add(tabla); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfCombos(Document doc, List<ComboPorModelo> combos) { Paragraph parrafo;/* w w w .java 2s .co m*/ PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; fuente = "arial"; if (combos.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Combos"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); doc.add(Chunk.NEWLINE); tabla = new PdfPTable(5); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Nombre", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Lavadas", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Modelo", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Precio", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (ComboPorModelo combo : combos) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(combo.getId()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getCombo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getCombo().getNumeroLavadas()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getModelo().getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase("S/. " + combo.getPrecio() + "0"); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(combo.getId() + ""); tabla.addCell(combo.getCombo().getNombre()); tabla.addCell(combo.getCombo().getNumeroLavadas() + ""); tabla.addCell(combo.getModelo().getNombre()); tabla.addCell("S/. " + combo.getPrecio() + "0"); } i++; } doc.add(tabla); doc.close(); } catch (DocumentException ex) { } }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfCombosReporte(Document doc, List<ComboReporte> combos, PdfWriter writer) { Paragraph parrafo;/*w w w.j a v a2s . co m*/ PdfPTable tabla; String txt; PdfPCell cell; Phrase frase; String fuente; int i; JFreeChart chart; int w, h; int pos; pos = 0; w = h = 500; fuente = "arial"; if (combos.isEmpty()) { return; } try { // // Se abre el documento. doc.open(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); txt = "Reporte de Combos"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 30, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_CENTER); doc.add(parrafo); LineSeparator ls = new LineSeparator(); doc.add(new Chunk(ls)); tabla = new PdfPTable(3); frase = new Phrase("Id", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Nombre", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); frase = new Phrase("Dinero Recaudado", FontFactory.getFont(fuente, 12, Font.BOLD, BaseColor.WHITE)); cell = new PdfPCell(frase); cell.setBackgroundColor(BaseColor.RED); tabla.addCell(cell); i = 1; for (ComboReporte combo : combos) { if (i % 2 == 0) { cell = new PdfPCell(); cell.setBackgroundColor(new BaseColor(244, 119, 119)); frase = new Phrase(combo.getId() + ""); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase(combo.getNombre()); cell.setPhrase(frase); tabla.addCell(cell); frase = new Phrase("S/. " + combo.getCantidad() + "0"); cell.setPhrase(frase); tabla.addCell(cell); } else { tabla.addCell(combo.getId() + ""); tabla.addCell(combo.getNombre()); tabla.addCell("S/. " + combo.getCantidad() + "0"); } i++; } doc.add(tabla); doc.newPage(); txt = "Miraflores Car Wash"; parrafo = new Paragraph(txt, FontFactory.getFont(fuente, 10, Font.BOLD, BaseColor.BLACK)); parrafo.setAlignment(Element.ALIGN_LEFT); doc.add(parrafo); chart = comboService.generarChartReporte(combos); w = 500; h = 500; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2d = tp.createGraphics(w, h, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, w, h); chart.draw(g2d, r2d); cb.addTemplate(tp, 50, 250); g2d.dispose(); doc.close(); } catch (DocumentException ex) { } }