List of usage examples for com.itextpdf.text Paragraph Paragraph
public Paragraph(float leading, String string)
Paragraph
with a certain String
and a certain leading. From source file:com.jpsycn.print.util.PDFUtils.java
private static Document setHeader(File file, Context mContext, Font simfang12, Font simfangBlod12, String title, String sno) throws DocumentException, IOException { Document document = new Document(PageSize.A4, 30, 30, 20, 0); PdfWriter.getInstance(document, new FileOutputStream(file)); document.open();// w w w . j a v a 2s. co m // Font simhei18 = FontUtil.getFont(mContext, 18, "simhei.ttf"); Paragraph b = new Paragraph(title, simhei18); b.setAlignment(Element.ALIGN_CENTER); document.add(b); // ? Chunk m1 = new Chunk("?", simfang12); Chunk m2 = new Chunk(sno, simfangBlod12); Paragraph p2 = new Paragraph(); p2.add(m1); p2.add(m2); p2.setAlignment(Element.ALIGN_RIGHT); document.add(p2); return document; }
From source file:com.jpsycn.print.util.PDFUtils.java
/** * ???/??//from w ww . j a v a2s. c o m * * @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 va2s . co 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.kohmiho.mpsr.export.PDFGenerator.java
@SuppressWarnings("unchecked") protected void fillColumnText(List<HashMap<String, Object>> bookmarkList, ColumnText ct, float leftIndent, int depth, Font font) { if (null != bookmarkList) { for (int i = 0; i < bookmarkList.size(); i++) { HashMap<String, Object> bookmark = bookmarkList.get(i); String title = (String) bookmark.get("Title"); String pageNum = ((String) bookmark.get("Page")).split(" ")[0]; Paragraph paragraph = null != font ? new Paragraph(title, font) : new Paragraph(title); // paragraph.add(new Chunk(new VerticalPositionMark())); paragraph.add(new Chunk(new DottedLineSeparator())); paragraph.add(Integer.toString((Integer.parseInt(pageNum) - 1))); paragraph.setIndentationLeft(leftIndent * depth); paragraph.setSpacingBefore(0 == depth ? 9 : 0); ct.addElement(paragraph);//from ww w . j a va2 s . c o m fillColumnText(((List<HashMap<String, Object>>) bookmark.get("Kids")), ct, leftIndent, depth + 1, null); } } }
From source file:com.leenmeij.app.utils.CreatePdf.java
/** * Create the content page of the PDF file * @param document/*from ww w . j av a2s .c o m*/ * @param invoice * @throws DocumentException */ private static void contentPage(Document document, Invoice invoice) throws DocumentException { // Get the customer information User user = new User(); user = user.getById(invoice.getUser_id()); // Create a chapter Chapter catPart = new Chapter(new Paragraph("LeenMeij Factuur gegevens", catFont), 1); // Add a sub paragraph Paragraph subParagraph = new Paragraph("Klantgegevens", subFont); Section subCatPart = catPart.addSection(subParagraph); // Set the user information subCatPart.add(new Paragraph("Naam: " + user.getFirstName() + " " + user.getLastName())); subCatPart.add(new Paragraph("Adres: " + user.getAddressLineOne() + " " + user.getAddressLineTwo())); subCatPart.add(new Paragraph("Woonplaats:" + user.getCity())); subCatPart.add(new Paragraph("Land: " + user.getCountry())); // Add another subparagraph subParagraph = new Paragraph("Huurgegevens:", subFont); subCatPart = catPart.addSection(subParagraph); // Format the date for showing purposes SimpleDateFormat format = new SimpleDateFormat("MM/dd/YYYY"); // Add the dates subCatPart.add(new Paragraph("Startdatum: " + format.format(invoice.getStartdate()))); subCatPart.add(new Paragraph("Einddatum: " + format.format(invoice.getEnddate()))); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table createTable(subCatPart, invoice); // now add all this to the document document.add(catPart); }
From source file:com.maxl.java.amikodesk.SaveBasket.java
License:Open Source License
private PdfPCell getStringCell(String str, Font font, int border, int align, int colspan) { PdfPCell cell = new PdfPCell(new Paragraph(str, font)); cell.setPaddingTop(5);//from w ww . ja va 2s .c om cell.setPaddingBottom(5); cell.setBorderWidth(1); cell.setBorder(border); cell.setHorizontalAlignment(align); cell.setVerticalAlignment(Element.ALIGN_MIDDLE /*.ALIGN_CENTER*/); cell.setColspan(colspan); return cell; }
From source file:com.microware.intrahealth.Createpdf2.java
public static Paragraph mypara(String ab, int flag) { Paragraph preface1 = new Paragraph(ab, subFont); if (flag == 1) preface1.setAlignment(Element.ALIGN_CENTER); if (flag == 2) preface1.setAlignment(Element.ALIGN_LEFT); if (flag == 3) preface1.setAlignment(Element.ALIGN_RIGHT); return preface1; }
From source file:com.miraflorescarwash.controller.PdfController.java
private void crearPdfLavadasPendientes(Document doc, List<Lavada> lavadas) { Paragraph parrafo;//w ww . j a v a 2s .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 (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;//from ww w .j a va2s .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 .jav a 2 s . 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) { } }