Example usage for com.itextpdf.text Font NORMAL

List of usage examples for com.itextpdf.text Font NORMAL

Introduction

In this page you can find the example usage for com.itextpdf.text Font NORMAL.

Prototype

int NORMAL

To view the source code for com.itextpdf.text Font NORMAL.

Click Source Link

Document

this is a possible style.

Usage

From source file:com.groupecom2015.entitieManager.MessageFacade.java

public void sendBuyingConfirmationEmail(List<ArticlePanier> listArt, CompteUser cu) {

    Date d = new Date(System.currentTimeMillis());
    Font font = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
    Font font_2 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL);
    Font font_3 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    double total = 0.0;
    String resume = "";
    try {/* www  .j  ava 2s  .  c o m*/
        // new File( System.getProperty( "user.home" ) +"/"+ cu.getIdCompte()).mkdirs();
        //String FILE = System.getProperty("user.home") +"/"+ cu.getIdCompte()+"/commandeRecu.pdf";
        new File("/home/umar/webapp_photo/uploads/" + cu.getIdCompte()).mkdirs();
        String FILE = "/home/umar/webapp_photo/uploads/" + cu.getIdCompte() + "/commandRecu.pdf";
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(FILE));
        document.open();

        Paragraph para = new Paragraph();
        para.add(new Paragraph(d + ""));
        para.add(new Paragraph(""));
        para.add(new Paragraph("Bonjour, " + cu.getNom(), font));
        para.add(new Paragraph("Veuillez trouvez ci-dessous votre le rsum de vos achat", font));
        para.add(new Paragraph(""));

        for (ArticlePanier l : listArt) {
            para.add(new Paragraph(
                    "" + l.getArticle().getNomArticle() + "     " + l.getArticle().getPrixVenteArticle(),
                    font_2));
            total += l.getArticle().getPrixVenteArticle();
            resume = resume + "\n" + l.getArticle().getNomArticle() + "  "
                    + l.getArticle().getPrixVenteArticle() + "\n";
        }
        para.add(new Paragraph("Total : " + total, font_3));
        para.add(new Paragraph(""));
        para.add(new Paragraph("Nous vous remercions pour votre achat", font_2));
        document.add(para);
        document.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

    //sending email with the pdf attached --> dropped

    final String from = "ecomgroup2015@gmail.com"; //ecomgroup2015@gmail.com
    final String to = "" + cu.getEmail();
    final String fileUpload = "/uploads/" + cu.getIdCompte() + "/commandRecu.pdf";
    try {
        Properties properties = new Properties();
        properties.put("mail.smtp.host", "smtp.gmail.com");
        properties.put("mail.smtp.port", "587"); //587
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.starttls.enable", "true");

        Session session = Session.getInstance(properties, new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(from, "groupeecom");
            }
        });

        javax.mail.Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(from));
        message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to));
        message.setSubject("Votre recipiss d'achat");
        message.setText("Bonjour " + cu.getNom() + "\n Veuillez trouvez ci-joint votre rsum d'achat\n"
                + "\n  " + resume + "  \n" + total);

        /*BodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText("Cher(e) "+cu.getNom()+"\n veuillez trouver ci-joint votre recipiss d'achat");
        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);
        messageBodyPart = new MimeBodyPart();
        String filename = "/uploads/"+cu.getIdCompte()+"/commandRecu.pdf";
        DataSource source = new FileDataSource(FILE);
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setFileName(FILE);
        multipart.addBodyPart(messageBodyPart);
                
        // Send the complete message parts
        message.setContent(multipart);*/
        Transport.send(message);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.icebreak.p2p.front.controller.trade.download.InvestReceiptPDFCreator.java

/**
 * ???//  w w  w.  j av a 2s .c o  m
 * @param tradeId
 * @param detailId
 * @param servletPath
 * @return ?  byte[]
 * @throws Exception
 */
public byte[] creatFileData4Receipt(long tradeId, long detailId, String servletPath) throws Exception {

    FileInputStream fis = null;
    BufferedInputStream buff = null;

    String fileKey = tradeId + "_" + detailId;//System.currentTimeMillis() + "";
    String filePath = servletPath + "/resources/pdf/investReceipt_" + fileKey + ".pdf";
    this.receiptFilePath = filePath;

    File file = new File(filePath);

    if (!file.exists()) {

        String timeLimit = "";
        String interestRate = "";
        String guaranteeName = "";
        String investFlowCode = null;
        String investor = "";
        String investorReal = "";
        String investorCertNo = "";
        String loanner = "";
        String loannerReal = "";
        String loannerCertNo = "";
        String investAmount = "";
        String totalAmountStr = "";
        String effectiveDate = "";
        String expireDate = "";

        Trade trade = tradeService.getByTradeId(tradeId);
        effectiveDate = DateUtil.simpleFormat(trade.getEffectiveDateTime());
        expireDate = DateUtil.simpleFormat(trade.getExpireDateTime());
        LoanDemandDO loanDemand = loanDemandManager.queryLoanDemandByDemandId(trade.getDemandId());
        guaranteeName = loanDemand.getGuaranteeName();
        if ("W".equals(loanDemand.getTimeLimitUnit()) || "M".equals(loanDemand.getTimeLimitUnit())) {
            timeLimit = loanDemand.getTimeLimit() + "";
        } else if ("Y".equals(loanDemand.getTimeLimitUnit())) {
            timeLimit = loanDemand.getTimeLimit() + "";
        } else {
            timeLimit = loanDemand.getTimeLimit() + "";
        }
        interestRate = CommonUtil.mul(loanDemand.getInterestRate(), 100) + "%";
        List<UserInvestEntry> userInvests = tradeService.getEntriesByTradeIdAndDetailId(tradeId, detailId);
        long totalAmount = 0;
        if (userInvests != null && userInvests.size() > 0) {
            UserInvestEntry tradeItem = userInvests.get(0);
            investAmount = MoneyUtil.getFormatAmount(tradeItem.getAmount());
            long investorId = userInvests.get(0).getInvestorId();
            long loannerId = userInvests.get(0).getLoanerId();
            investorCertNo = getCertNoByUserId(investorId);
            loannerCertNo = getCertNoByUserId(loannerId);
            investor = userInvests.get(0).getInvestorUserName();
            investorReal = userInvests.get(0).getInvestorRealName();
            loannerReal = userInvests.get(0).getLoanerRealName();
            loanner = userInvests.get(0).getLoanerUserName();
            totalAmount = userInvests.get(0).getAmount();
        }

        //?
        /*interest = caculateInterest(new Money(totalAmount), loanDemand.getInterestRate(),
        loanDemand.getTimeLimit(), loanDemand.getTimeLimitUnit());*/

        long divisionAmount = 0;
        long profitAmount = 0;
        List<TradeDetail> details = tradeService.getInvestProfitTrade(detailId);
        if (details != null && details.size() > 0) {
            for (TradeDetail detail : details) {
                divisionAmount += detail.getAmount();
                if (detail.getProfitType() > 0) {
                    profitAmount += detail.getAmount();
                }
            }
        }
        totalAmount += divisionAmount;

        TradeFlowCode tradeFlow = tradeService.queryInvestFlowCodesByTradeDetailId(detailId);
        if (tradeFlow != null) {
            investFlowCode = tradeFlow.getTradeFlowCode();
        }

        String guaranteeLicenseNo = "";
        Map<String, Object> cond = new HashMap<String, Object>();
        cond.put("roleId", 8L);

        cond.put("tradeId", trade.getId());
        List<TradeQueryDetail> det = loanDemandManager.getTradeDetailByConditions(cond);
        if (det != null && det.size() > 0) {
            tradeFlow = tradeService.queryInvestFlowCodesByTradeDetailId(det.get(0).getId());
            if (tradeFlow != null) {
                guaranteeLicenseNo = tradeFlow.getTradeFlowCode();
            }
        }

        LoanDemandDO demand = loanDemandManager.queryLoanDemandByDemandId(trade.getDemandId());
        long divisionTemplateId = demand.getDivisionTemplateId();
        DivisionTemplateLoanDO divisionTemplateLoan = divisionTemplateLoanService
                .getByBaseId(divisionTemplateId);
        List<DivsionRuleRole> investRolelist = divisionService
                .getRuleRole(String.valueOf(divisionTemplateLoan.getInvestTemplateId()));
        List<DivsionRuleRole> repayRolelist = divisionService
                .getRuleRole(String.valueOf(divisionTemplateLoan.getRepayTemplateId()));
        //??
        double totalAnnualInterest = 0;
        investRolelist.addAll(repayRolelist);
        if (investRolelist != null && investRolelist.size() > 0) {
            for (DivsionRuleRole druleRole : investRolelist) {
                if (DivisionPhaseEnum.INVESET_PHASE.code().equals(druleRole.getPhase())) {
                    if ("11".equals(String.valueOf(druleRole.getRoleId()))) {
                        totalAnnualInterest += druleRole.getRule();
                    }

                }
            }
        }

        totalAmountStr = MoneyUtil.getFormatAmount(totalAmount);
        String divisionAmountStr = MoneyUtil.getFormatAmount(divisionAmount);

        FileOutputStream fos = null;
        Document doc = new Document(PageSize.A4, 20, 20, 140, 20);
        try {
            fos = new FileOutputStream(filePath);
            PdfWriter writer = PdfWriter.getInstance(doc, fos);
            doc.open();
            //   
            BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
            Font titleChinese = new Font(bfChinese, 20, Font.BOLD); // ?     
            Paragraph title = new Paragraph(AppConstantsUtil.getProductName() + "?", titleChinese);// 
            title.setAlignment(Element.ALIGN_CENTER); // 
            title.setLeading(1f);//?//?
            doc.add(title);

            Font fontZH = new Font(bfChinese, 12, Font.NORMAL);
            float[] widths = { 20f, 30f, 25f, 25f };
            PdfPTable table = new PdfPTable(widths);

            table.setSpacingBefore(20f);// ?
            table.setTotalWidth(500);// 
            table.setWidthPercentage(100);//%100
            // table.getDefaultCell().setBorder(0);//
            PdfPCell cell;
            //               cell = new PdfPCell(new Paragraph("?",fontZH));
            //               cell.setColspan(4);
            //               table.addCell(cell);

            cell = new PdfPCell(new Paragraph("??", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(AppConstantsUtil.getPlatformName(), fontZH));
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("?", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(loanDemand.getRepayDivisionWayMsg(), fontZH));
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(interestRate, fontZH));
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("?", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(timeLimit, fontZH));
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("??", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(guaranteeName, fontZH));
            cell.setColspan(3);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("??", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(
                    new Paragraph(StringUtil.nullToEmpty(loanDemand.getGuaranteeLicenseNo()), fontZH));
            cell.setColspan(3);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph((loanDemand.getLoanAmount() / 100) + "", fontZH));
            cell.setColspan(3);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(loanDemand.getLoanPurpose(), fontZH));
            cell.setColspan(3);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("??", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph(investFlowCode, fontZH));
            cell.setColspan(3);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("?", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell.setColspan(2);
            table.addCell(cell);

            cell = new PdfPCell(new Paragraph("??", fontZH));
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            cell.setColspan(2);

            table.addCell(cell);
            Paragraph iparas = new Paragraph("??" + investor, fontZH);
            iparas.add(Chunk.NEWLINE);
            iparas.add("??" + investorReal);
            iparas.add(Chunk.NEWLINE);
            iparas.add("??" + StringUtil.subString(investorCertNo, 7, "****"));
            iparas.add(Chunk.NEWLINE);
            iparas.add("?" + effectiveDate);
            iparas.add(Chunk.NEWLINE);
            iparas.add("" + expireDate);
            iparas.add(Chunk.NEWLINE);
            iparas.add("()" + investAmount);
            iparas.add(Chunk.NEWLINE);
            iparas.add("()" + divisionAmountStr);
            iparas.add(Chunk.NEWLINE);
            iparas.add("()" + totalAmountStr);

            cell = new PdfPCell(iparas);
            cell.setColspan(2);
            cell.setRowspan(8);

            cell.setMinimumHeight(120);
            table.addCell(cell);
            Paragraph paras = new Paragraph("??" + loanner, fontZH);
            paras.add(Chunk.NEWLINE);
            paras.add("??" + loannerReal);
            paras.add(Chunk.NEWLINE);
            paras.add("??" + StringUtil.subString(loannerCertNo, 7, "****"));
            paras.add(Chunk.NEWLINE);
            paras.add("?" + effectiveDate);
            paras.add(Chunk.NEWLINE);
            paras.add("" + expireDate);
            paras.add(Chunk.NEWLINE);
            paras.add(Chunk.NEWLINE);
            paras.add(Chunk.NEWLINE);
            paras.add("()" + totalAmountStr);
            cell = new PdfPCell(paras);
            cell.setColspan(2);
            cell.setRowspan(8);
            table.addCell(cell);
            doc.add(table);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            Paragraph tips = new Paragraph("  ?? ?"
                    + AppConstantsUtil.getPlatformName() + "", fontZH);// 
            tips.setLeading(1f);//?//?
            doc.add(tips);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            doc.add(Chunk.NEWLINE);
            tips = new Paragraph("  ??" + AppConstantsUtil.getPlatformAddress(), fontZH);// 
            tips.setLeading(1f);//?//?
            doc.add(tips);
            //               XMLWorkerHelper.getInstance().parseXHtml(writer, doc,
            //                     new ByteArrayInputStream(str.getBytes()));
            doc.close();
            logger.info("?");

        } catch (Exception e) {
            logger.error("?", e);
            throw new Exception("?:" + e.getMessage());
        } finally {

            if (fos != null) {
                fos.close();
            }
        }
    }

    byte[] data = new byte[1024];

    file = new File(filePath);
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] temp = new byte[1024];
        int size = 0;

        fis = new FileInputStream(file);
        buff = new BufferedInputStream(fis);

        int i = 0;

        while ((size = buff.read(temp)) != -1) {
            out.write(temp, 0, size);
            i += 1;
        }

        data = out.toByteArray();

        buff.close();
        fis.close();
        //file.delete();

        if (i == 0 && size == -1) { //PDF
            file.delete();
        }
    } catch (FileNotFoundException e) {
        logger.error("?", e);
    } catch (IOException e) {
        logger.error("delete file", e);
    } finally {
        if (fis != null) {
            fis.close();
        }
    }

    return data;
}

From source file:com.innoq.iQpdfutil.Main.java

License:Open Source License

/**
 * This method adds a page number to all pages (except the first one)
 * from the given input pdf and writes the modified pdf to
 * the output-stream.// w  w w  . ja va 2  s  .  c om
 *
 * <p>
 * The page number is placed in the center at the bottom of the page.
 * </p>
 *
 * <pre>
 *  +-----+
 *  |     |
 *  |     |
 *  |     |
 *  | -2- |
 *  +-----+
 * </pre>
 * */
private static void numberPages(PdfReader reader, OutputStream os) throws IOException, DocumentException {

    PdfStamper stamper = new PdfStamper(reader, os);

    try {
        int n = reader.getNumberOfPages();

        ColumnText text;
        PdfContentByte contents;
        Paragraph paragraph;
        Font headerFont = new Font(Font.FontFamily.COURIER, 12, Font.NORMAL);
        for (int i = 2; i <= n; i++) {
            contents = stamper.getOverContent(i);
            text = new ColumnText(contents);
            text.setSimpleColumn(1, 10, PageSize.A4.getWidth() - 1, 30, 1, Element.ALIGN_CENTER);
            paragraph = new Paragraph(String.format("- %d -", i), headerFont);
            paragraph.setAlignment(Element.ALIGN_CENTER);
            text.addElement(paragraph);
            text.go();
        }
    } finally {
        try {
            stamper.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:com.iox.rms.mbean.UserBean.java

@SuppressWarnings("deprecation")
private byte[] generateInvoiceForCustomerPurchase(CustomerProduct cp) {
    byte[] data = null;

    if (cp != null) {
        Document document = new Document();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {/*from   w  ww . j  a va2  s  . c o m*/
            PdfWriter writer = PdfWriter.getInstance(document, baos);
            writer.setPageEvent(new HeaderFooter());
            writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788));
            if (!document.isOpen()) {
                document.open();
            }
            document.setPageSize(PageSize.A4);
            document.addAuthor("AutoLife");
            document.addCreationDate();
            document.addCreator("AutoLife");
            document.addSubject("Invoice");
            document.addTitle("Purchase Invoice");

            PdfPTable headerTable = new PdfPTable(3);

            ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance()
                    .getExternalContext().getContext();
            String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator
                    + "sattrak-logo.png";
            PdfPCell c = new PdfPCell(Image.getInstance(logo));
            c.setBorder(0);
            c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            headerTable.addCell(c);

            BaseFont helvetica = null;
            try {
                helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
            } catch (Exception e) {
            }
            Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD);
            c = new PdfPCell(new Paragraph("INVOICE", font));
            c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            c.setBorder(0);
            headerTable.addCell(c);

            font = new Font(helvetica, 10, Font.NORMAL | Font.BOLD);
            c = new PdfPCell(new Paragraph("TRANSACTION REF. NO.: " + cp.getPurchaseTranRef(), font));
            c.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            c.setBorder(0);
            headerTable.addCell(c);

            document.add(headerTable);

            font = new Font(helvetica, 12, Font.NORMAL | Font.BOLD);
            Paragraph p = new Paragraph("DETAILS", font);
            p.setAlignment(Paragraph.ALIGN_CENTER);
            document.add(p);

            PdfPTable pdfTable = new PdfPTable(3);

            font = new Font(helvetica, 8, Font.BOLDITALIC);
            pdfTable.addCell(new Paragraph("INITIATED DATE", font));
            pdfTable.addCell(new Paragraph("PRODUCT", font));
            pdfTable.addCell(new Paragraph("AMOUNT", font));
            font = new Font(helvetica, 8, Font.NORMAL);
            pdfTable.addCell(
                    new Paragraph(cp.getPurchaseTransaction().getTranInitDate().toLocaleString(), font));
            pdfTable.addCell(new Paragraph(cp.getProductBooked().getDetails(), font));
            pdfTable.addCell(new Paragraph("" + cp.getPurchasedAmount(), font));
            document.add(pdfTable);

            document.close();

            data = baos.toByteArray();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    return data;
}

From source file:com.jpsycn.print.util.PDFUtils.java

/**
 * ?????// w ww  .j  a  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

/**
 * ???/??// w w  w . ja  v  a2 s  .c  om
 * 
 * @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  w w . j a v  a2s  .  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.miraflorescarwash.controller.PdfController.java

private void crearPdfCliente(Document doc, Cliente cliente) {
    Paragraph parrafo;//from   w  ww . j av a  2s . com
    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 w  w w  . j a va  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) {

    }
}

From source file:com.miraflorescarwash.controller.PdfController.java

private void crearPdfVentasReporte(Document doc, JFreeChart chart, PdfWriter writer, String fechaInicio,
        String fechaFin) {/*from   ww  w .  ja  va2  s  .  c  om*/
    Paragraph parrafo;
    Phrase frase;
    String txt;
    String fuente;
    int w, h;

    fuente = "arial";
    if (chart == null) {
        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 Ventas";
        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 = "Inicio: ";
        frase = new Phrase(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK));
        doc.add(frase);
        txt = fechaInicio;
        frase = new Phrase(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK));
        doc.add(frase);
        doc.add(Chunk.NEWLINE);

        txt = "Fin: ";
        frase = new Phrase(txt, FontFactory.getFont(fuente, 14, Font.BOLD, BaseColor.BLACK));
        doc.add(frase);
        txt = fechaFin;
        frase = new Phrase(txt, FontFactory.getFont(fuente, 14, Font.NORMAL, BaseColor.BLACK));
        doc.add(frase);

        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, 50);
        g2d.dispose();
        doc.close();
    } catch (DocumentException ex) {

    }
}