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.gadroves.gsisinve.controller.FacturarController.java
void PrintToPDF(TbFacturaVenta facturaVenta, TbCLienteFactura cLienteFactura) throws DocumentException, IOException { Font header = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD); Font normalBold = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font normal = new Font(Font.FontFamily.HELVETICA, 12); String fileName = "Factura_" + facturaVenta.getId() + ".pdf"; // step 1// w w w .j a v a 2 s . c om Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(fileName)); // step 3 document.open(); // step 4 document.add(new Paragraph("Gadroves S.A Factura De Venta", header)); document.add(new Paragraph(" ")); document.add(new Paragraph("Factura N" + facturaVenta.getId(), normalBold)); document.add(new Chunk("Cliente: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getName(), normal)); document.add(new Paragraph()); document.add(new Chunk("Direccin: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getAddress(), normal)); document.add(new Paragraph()); document.add(new Chunk("Identificacion: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getId(), normal)); document.add(new Paragraph()); document.add(new Chunk("Credito: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(Boolean.FALSE.toString(), normal)); document.add(new Paragraph()); for (int i = 0; i < 3; i++) document.add(new Paragraph(" ")); createItemsTable(document, facturaVenta); document.add(new Paragraph(" ")); Paragraph subs = new Paragraph(); subs.setAlignment(Element.ALIGN_RIGHT); subs.setIndentationRight(40); subs.add(new Chunk("Subtotal: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getSub())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Impuestos: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getImpuestos())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Total: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getTotal())))); subs.add(Chunk.NEWLINE); document.add(subs); // step 5 document.close(); Desktop.getDesktop().open(new File(fileName)); }
From source file:com.github.luischavez.levsym.modulos.funcion.PDF.java
License:Open Source License
public void GeneraPDF(ResultSet Resultados) throws Exception { ResultSetMetaData metaData = Resultados.getMetaData(); Object[] Columnas = new Object[metaData.getColumnCount()]; String encabezado = "Reportes del Sistema Administrativo" + "\n" + "REGISTROS ACTUALES EN AL BASE DE DATOS" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; Calendar c = Calendar.getInstance(); String date = Integer.toString(c.get(Calendar.DAY_OF_MONTH)) + "-" + Integer.toString(c.get(Calendar.MONTH)) + "-" + Integer.toString(c.get(Calendar.YEAR)) + " " + Integer.toString(c.get(Calendar.HOUR_OF_DAY)) + "-" + Integer.toString(c.get(Calendar.MINUTE)) + "-" + Integer.toString(c.get(Calendar.SECOND)); Font fuente = new Font(Font.getFamily("ARIAL"), 12, Font.BOLD); String choro = "Reporte por fecha de los modulos\n" + "de catalogo" + "\n" + "Systema Administrativo" + "\n" + "\n" + "\n" + "\n"; Image imagen = Image.getInstance(System.getProperty("user.dir") + "/Image/logo.png"); imagen.setAlignment(Image.TEXTWRAP); try {/*w w w. j a v a 2s . c om*/ Paragraph linea = new Paragraph(encabezado, fuente); Phrase para = new Phrase(choro); Paragraph fecha = new Paragraph(date + "\n" + "\n"); PdfPTable tabla = new PdfPTable(Columnas.length); tabla.setWidthPercentage(100); //Document documento = new Document(PageSize.LETTER); Document documento = new Document(PageSize.A4.rotate(), 50, 50, 100, 72); File Dir = new File(System.getProperty("user.dir") + "/Reportes/"); if (!Dir.exists()) { Dir.mkdirs(); } String file = System.getProperty("user.dir") + "/Reportes/" + metaData.getTableName(1) + " " + date + ".pdf"; PdfWriter.getInstance(documento, new FileOutputStream(file)); documento.open(); documento.add(imagen); documento.add(linea); documento.add(para); documento.add(fecha); for (int x = 0; x < Columnas.length; x++) { PdfPCell Celda = new PdfPCell(new Paragraph(metaData.getColumnName(x + 1), FontFactory.getFont("arial", 9, Font.BOLD, BaseColor.RED))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } while (Resultados.next()) { for (int x = 0; x < Columnas.length; x++) { //if(Resultados.getObject(x+1).getClass().getSimpleName().equals("Integer")) PdfPCell Celda = new PdfPCell(new Paragraph(String.valueOf(Resultados.getObject(x + 1)), FontFactory.getFont("arial", 9, BaseColor.BLACK))); Celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(Celda); } } documento.add(tabla); documento.close(); } catch (DocumentException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IOException e) { Log.SaveLog(e.toString()); JOptionPane.showMessageDialog(null, e.getMessage(), "error", JOptionPane.ERROR_MESSAGE); } }
From source file:com.gp.cong.logisoft.reports.DeliveryOrderPdfCreator.java
public PdfPTable lineTable(FclBl bl, String deliveryDate, String realPath) throws Exception { PdfPCell cell = new PdfPCell(); PdfPCell celL = new PdfPCell(); String path = LoadLogisoftProperties.getProperty("application.image.logo"); String econoPath = LoadLogisoftProperties.getProperty("application.image.econo.logo"); String companyCode = new SystemRulesDAO().getSystemRulesByCode("CompanyCode"); PdfPTable table = new PdfPTable(4); table.setWidthPercentage(100);//from www. j a v a 2 s . com Paragraph p = null; cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); if (null != bl && bl.getBrand().equalsIgnoreCase("Econo") && ("03").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("OTI") && ("02").equals(companyCode)) { Image img = Image.getInstance(realPath + econoPath); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } else if (null != bl && bl.getBrand().equalsIgnoreCase("Ecu Worldwide")) { Image img = Image.getInstance(realPath + path); img.setAlignment(Element.ALIGN_CENTER); img.scalePercent(60); img.setAlignment(Element.ALIGN_TOP); cell.addElement(img); } table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DELIVERY ORDER", blackBoldFontheading); p.setAlignment(Element.ALIGN_CENTER); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setColspan(4); cell.setBorder(0); p = new Paragraph("DATE PRINTED : " + DateUtils.formatStringDateToAppFormatMMM(new Date()), blackFontForAR); p.setAlignment(Element.ALIGN_RIGHT); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "CONSIGNEE NAME", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "DATE:", blackFontForAR); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthBottom(0f); p = new Paragraph(8f, "REF:", blackFontForAR); cell.addElement(p); table.addCell(cell); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeName()) ? bl.getConsigneeName() : ""); stringBuilder.append("\n"); stringBuilder.append(CommonUtils.isNotEmpty(bl.getConsigneeAddress()) ? bl.getConsigneeAddress() : ""); cell = new PdfPCell(); cell.setRowspan(2); cell.setBorderWidthTop(0f); p = new Paragraph(8f, stringBuilder.toString(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, deliveryDate, blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorderWidthTop(0f); p = new Paragraph(8f, "04-" + bl.getFileNo(), blackFont); cell.addElement(p); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(); cell.setBorder(0); cell.setColspan(2); p = new Paragraph(8f, "THE MERCHANDISE DESCRIBED BELOW WILL BE ENTERED AND FORWARDED AS FOLLOWS:", blackFontForAR); p.setAlignment(Element.ALIGN_LEFT); cell.addElement(p); table.addCell(cell); return table; }
From source file:com.icebreak.p2p.front.controller.trade.download.InvestReceiptPDFCreator.java
/** * ???/*from www. j av a 2 s . c om*/ * @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.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public Boolean createFrontCoverPage(Document document, String coverTitle, Bitmap photo) throws DocumentException, MalformedURLException, IOException { if (photo != null) { int imageMaxWidth; int imageMaxHeight; int imagePosX; int imagePosY; if (photo.getWidth() < photo.getHeight()) { imageMaxWidth = 900;// ww w . j a v a 2 s .co m imageMaxHeight = 1200; imagePosX = 198; imagePosY = 379; } else { imageMaxWidth = 1200; imageMaxHeight = 900; imagePosX = 162; imagePosY = 379; } OutputStream stream = new ByteArrayOutputStream(); ImageUtilities.scaleCenterCrop(photo, imageMaxWidth, imageMaxHeight).compress(CompressFormat.JPEG, 50, stream); Image coverImage = Image.getInstance(stream.toByteArray()); coverImage.setAbsolutePosition(0.0f, 0.0f); PdfTemplate t = this.writer.getDirectContent().createTemplate((float) imageMaxWidth, (float) imageMaxHeight); t.newPath(); t.moveTo(0.0f, (float) imageMaxHeight); t.lineTo(0.0f, 71.0f); t.lineTo(17.0f, 71.0f); t.lineTo(17.0f, 0.0f); t.lineTo(72.0f, 71.0f); t.lineTo((float) imageMaxWidth, 71.0f); t.lineTo((float) imageMaxWidth, (float) imageMaxHeight); t.lineTo(0.0f, (float) imageMaxHeight); t.closePath(); t.clip(); t.newPath(); t.addImage(coverImage); t.setColorStroke(new BaseColor(0, 0, 0)); t.setLineWidth(BUBBLE_TEXT_INDENT_ALTERNATE); t.newPath(); t.moveTo(0.0f, (float) imageMaxHeight); t.lineTo(0.0f, 71.0f); t.lineTo(17.0f, 71.0f); t.lineTo(17.0f, 0.0f); t.lineTo(72.0f, 71.0f); t.lineTo((float) imageMaxWidth, 71.0f); t.lineTo((float) imageMaxWidth, (float) imageMaxHeight); t.lineTo(0.0f, (float) imageMaxHeight); t.closePathStroke(); Image clipped = Image.getInstance(t); clipped.scalePercent(24.0f); clipped.setAbsolutePosition((float) imagePosX, (float) imagePosY); clipped.setCompressionLevel(this.settings.compressionLevel); clipped.setAlignment(5); document.add(clipped); } if (coverTitle != null && coverTitle.length() > 0) { PdfContentByte canvas = this.writer.getDirectContent(); Paragraph coverTitleEl = new Paragraph(coverTitle, this.serifFont24); coverTitleEl.setAlignment(1); PdfPTable table = new PdfPTable(1); table.setTotalWidth(311.0f); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(coverTitleEl); cell.setPadding(0.0f); cell.setIndent(0.0f); table.addCell(cell); table.completeRow(); table.writeSelectedRows(0, -1, 147.0f, 390.0f, canvas); } return Boolean.valueOf(true); }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public Boolean createBackCoverPage(Document document, String backCoverNote) throws DocumentException, MalformedURLException, IOException { document.newPage();/*from w w w. jav a2s . c om*/ Image backCoverImageFrame = Image .getInstance(ImageUtilities.getImageDataForFile(this.mContext, "pdf/txtbook_backpage_300.png")); backCoverImageFrame.scalePercent(24.0f); backCoverImageFrame.setAbsolutePosition(87.0f, 78.0f); backCoverImageFrame.setCompressionLevel(this.settings.compressionLevel); document.add(backCoverImageFrame); PdfContentByte canvas = this.writer.getDirectContent(); PdfPTable table = new PdfPTable(1); table.setTotalWidth(215.0f); if (backCoverNote != null && backCoverNote.length() > 0) { Paragraph backCoverEl = new Paragraph(backCoverNote, this.serifFont14); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(backCoverEl); cell.setPadding(13.0f); cell.setIndent(0.0f); cell.setFixedHeight(310.0f); table.addCell(cell); table.completeRow(); } Element backUrl = new Anchor("txt-book.com", this.sansFont11Gray); backUrl.setName("txt-book.com"); backUrl.setReference("http://www.txt-book.com"); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(2); paragraph.add(backUrl); PdfPCell cell2 = new PdfPCell(); cell2.setBorder(0); cell2.setHorizontalAlignment(2); cell2.addElement(paragraph); cell2.setPadding(0.0f); cell2.setPaddingTop(0.0f); cell2.setIndent(0.0f); table.addCell(cell2); table.completeRow(); table.writeSelectedRows(0, -1, 306.0f, 400.0f, canvas); return Boolean.valueOf(true); }
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./*from w w w . j av a 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 w w . j a v a 2s .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.javaPdf.app.GeneradorContrato.java
public static void writePDF() { // Document document = new Document() ; Document document = new Document(PageSize.LETTER, 65, 65, 60, 60); try {//from w ww . ja va 2 s . c om /*Font que usaran las palabras destacadas con NEGRITA*/ Font font_negrita = FontFactory.getFont("Times New Roman"); font_negrita.setSize(11); font_negrita.setStyle(Font.BOLD); font_negrita.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Scanner sc = new Scanner(System.in); Calendar calendarioGragoriano = new GregorianCalendar(12, Calendar.MONTH, 2017); /*Inicializar un objeto de tipo Calendar con un metodo de clase (Static) el cual obtiene una onstancia de la clase puede ser mas sencillo*/ Calendar calendario = Calendar.getInstance(); System.out.println(Calendar.DAY_OF_MONTH); System.out.println(calendario.getTime()); /*Datos ingresados por teclado*/ System.out.println("Ingrese el NOMBRE DEL EMPLEADOR: "); Chunk nombreEmpleador = new Chunk("[EMPLEADOR]", font_negrita); System.out.println("Ingrese el RUT DEL EMPLEADOR: "); Chunk rutEmpleador = new Chunk("xx.xxx.xxx-x", font_negrita); System.out.println("Ingrese el NOMBRE DEL TRABAJADOR: "); // Chunk nombreTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk nombreTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese el RUT DEL TRABAJADOR: "); // Chunk rutTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk rutTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la DIRECCIN DEL TRABAJADOR: "); // Chunk direccionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk direccionTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la COMUNA DEL TRABAJADOR: "); // Chunk comunaTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk comunaTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FECHA DE NACIMIENTO DEL TRABAJADOR: "); // Chunk fechaNacimientoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaNacimientoTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese el SUELDO QUE TENDRA EL TRABAJADOR: "); // Chunk sueldoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk sueldoTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FUNCION QUE TENDRA EL TRABAJADOR: "); // Chunk funcionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk funcionTrabajador = new Chunk(sc.nextLine().toUpperCase(), font_negrita); System.out.println("Ingrese la FECHA DE INICIO DE CONTRATO DEL TRABAJADOR: "); // Chunk fechaInicioContrato = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaInicioContrato = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FECHA DE TERMINO DE CONTRATO DEL TRABAJADOR: "); // Chunk fechaTerminoContrato = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaTerminoContrato = new Chunk(sc.nextLine(), font_negrita); /*Clausulas*/ Chunk primero = new Chunk(TEXTOPRIMERO, font_negrita); Chunk segundo = new Chunk(TEXTOSEGUNDO, font_negrita); Chunk tercero = new Chunk(TEXTOTERCERO, font_negrita); Chunk cuarto = new Chunk(TEXTOCUARTO, font_negrita); Chunk quinto = new Chunk(TEXTOQUINTO, font_negrita); Chunk sexto = new Chunk(TEXTOSEXTO, font_negrita); Chunk septimo = new Chunk(TEXTOSEPTIMO, font_negrita); Chunk octavo = new Chunk(TEXTOOCTAVO, font_negrita); Chunk noveno = new Chunk(TEXTONOVENO, font_negrita); // Chunk afp = new Chunk (TEXTONOVENO2, font_negrita); // Chunk salud = new Chunk (TEXTONOVENO4, font_negrita); // Chunk cesantia = new Chunk (TEXTONOVENO6, font_negrita); Chunk decimo = new Chunk(TEXTODECIMO, font_negrita); Chunk undecimo = new Chunk(TEXTOUNDECIMO, font_negrita); // Calendar calendario = Calendar.getInstance(); SimpleDateFormat formateador = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("es")); Date fechaDate = new Date(); Chunk fecha = new Chunk(formateador.format(fechaDate), font_negrita); String path = new File(".").getCanonicalPath(); String FILE_NAME = path + "/CONTRATO " + nombreTrabajador + " RUT " + rutTrabajador + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(new File(FILE_NAME))); // Image firmaEmpleador = Image.getInstance(path + "/img/firmaEmpleador.png"); // firmaEmpleador.scaleAbsoluteWidth(150f); // firmaEmpleador.scaleAbsoluteHeight(70f); // firmaEmpleador.setAbsolutePosition(70f, 200f); // Image timbreGerencia = Image.getInstance(path + "/img/timbreGerencia.png"); timbreGerencia.scaleAbsoluteWidth(90f); timbreGerencia.scaleAbsoluteHeight(75f); timbreGerencia.setAbsolutePosition(230, 200f); // Image firmaTrabajador = Image.getInstance(path + "/img/firmaTrabajador.png"); firmaTrabajador.scaleAbsoluteWidth(160f); firmaTrabajador.scaleAbsoluteHeight(70f); firmaTrabajador.setAbsolutePosition(350, 175f); // // Image todoEnUno = Image.getInstance(path + "/img/todoEnUno.png"); // todoEnUno.scaleAbsoluteWidth(550); // todoEnUno.scaleAbsoluteHeight(150); // todoEnUno.setAbsolutePosition(15, 120f); document.open(); FontFactory.registerDirectories(); /*Parrafo de Titulo*/ String tituloContrato_texto = "CONTRATO DE TRABAJO:\n"; Font font_titulo = FontFactory.getFont("Times New Roman"); font_titulo.setSize(14); font_titulo.setStyle(Font.BOLD | Font.UNDERLINE); font_titulo.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Paragraph parrafoTitulo = new Paragraph(tituloContrato_texto, font_titulo); parrafoTitulo.setAlignment(Element.ALIGN_CENTER); document.add(parrafoTitulo); Font font_primer_parrafo = FontFactory.getFont("Times New Roman"); font_primer_parrafo.setSize(11); // font_primer_parrafo.setStyle(Font.BOLD | Font.UNDERLINE); font_primer_parrafo.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Paragraph primer_parrafo = new Paragraph(); /*Agregar CHunks a el parrafo*/ /*PRIMER PARRAFO*/ primer_parrafo.setAlignment(Element.ALIGN_JUSTIFIED); primer_parrafo.setLeading(15); primer_parrafo.setFont(font_primer_parrafo); primer_parrafo.add(TEXTO1); primer_parrafo.add(fecha); primer_parrafo.add(TEXTO2); primer_parrafo.add(nombreEmpleador); primer_parrafo.add(TEXTO3); primer_parrafo.add(rutEmpleador); primer_parrafo.add(TEXTO4); primer_parrafo.add(nombreTrabajador); primer_parrafo.add(TEXTO5); primer_parrafo.add(rutTrabajador); primer_parrafo.add(TEXTO6); primer_parrafo.add(direccionTrabajador); primer_parrafo.add(TEXTO7); primer_parrafo.add(comunaTrabajador); primer_parrafo.add(TEXTO8); primer_parrafo.add(fechaNacimientoTrabajador); primer_parrafo.add(TEXTO9); /*PRIMERA CLAUSULA*/ primer_parrafo.add(primero); primer_parrafo.add(TEXTOPRIMERO1); primer_parrafo.add(funcionTrabajador); primer_parrafo.add(TEXTOPRIMERO2); /*SEGUNDA CLAUSULA*/ primer_parrafo.add(segundo); // primer_parrafo.add(TEXTOSEGUNDO1); /*TERCERA CLAUSULA*/ primer_parrafo.add(tercero); primer_parrafo.add(TEXTOTERCERO1); primer_parrafo.add(Chunk.TABBING); primer_parrafo.add(TEXTOTERCERO2A); primer_parrafo.add(sueldoTrabajador); primer_parrafo.add(TEXTOTERCERO3A); primer_parrafo.add(Chunk.TABBING); primer_parrafo.add(TEXTOTERCERO4B); /*CUARTA CLAUSULA*/ primer_parrafo.add(cuarto); // primer_parrafo.add(TEXTOCUARTO1); /*QUINTA CLAUSULA*/ primer_parrafo.add(quinto); // primer_parrafo.add(TEXTOQUINTO1); /*SEXTA CLAUSULA*/ primer_parrafo.add(sexto); // primer_parrafo.add(TEXTOSEXTO1); /*SEPTIMA CLAUSULA*/ primer_parrafo.add(septimo); // primer_parrafo.add(TEXTOSEPTIMO1); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO2A); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO3B); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO4C); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO5D); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO6E); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO7F); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO8G); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO9H); /*OCTAVA CLAUSULA*/ primer_parrafo.add(octavo); // primer_parrafo.add(TEXTOOCTAVO1); /*NOVENA CLAUSULA*/ primer_parrafo.add(noveno); // primer_parrafo.add(TEXTONOVENO1); // primer_parrafo.add(afp); // primer_parrafo.add(TEXTONOVENO3); // primer_parrafo.add(salud); // primer_parrafo.add(TEXTONOVENO5); // primer_parrafo.add(cesantia); /*public static final String TEXTONOVENO2 = " PROVIDA"; public static final String TEXTONOVENO3 = " Salud:"; public static final String TEXTONOVENO4 = "FONASA"; public static final String TEXTONOVENO5 = ", y las de cesanta en:"; public static final String TEXTONOVENO6 = " AFC. \n\n";*/ /*DCIMA CLAUSULA*/ primer_parrafo.add(decimo); primer_parrafo.add(TEXTODECIMO1); primer_parrafo.add(fechaInicioContrato); primer_parrafo.add(TEXTODECIMO2); primer_parrafo.add(fechaTerminoContrato); primer_parrafo.add(TEXTODECIMO3); /*UNDECIMA CLAUSULA*/ primer_parrafo.add(undecimo); // primer_parrafo.add(TEXTOUNDECIMO1); document.add(primer_parrafo); // document.add(todoEnUno); document.add(timbreGerencia); document.add(firmaTrabajador); document.addAuthor("IGVI"); document.addTitle("CONTRATO DE TRABAJO IGVI"); document.close(); } catch (DocumentException e) { e.getMessage(); } catch (IOException e) { e.getMessage(); } }
From source file:com.jpsycn.print.util.PDFUtils.java
/** * ?????//from w ww . ja v a2s. 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; } }