List of usage examples for com.itextpdf.text BaseColor BLACK
BaseColor BLACK
To view the source code for com.itextpdf.text BaseColor BLACK.
Click Source Link
From source file:de.domjos.schooltools.activities.ApiActivity.java
License:Open Source License
private boolean exportPDF(String path, String type, String where) { try {// w w w. j av a 2 s .c o m File emptyPDF = new File(path); if (!emptyPDF.exists()) { if (!emptyPDF.createNewFile()) { return false; } } PDFBuilder pdfBuilder = new PDFBuilder(emptyPDF.getAbsolutePath(), this.getApplicationContext()); pdfBuilder.addFont("header", Font.FontFamily.HELVETICA, 32, true, true, BaseColor.BLACK); pdfBuilder.addFont("subHeader", Font.FontFamily.HELVETICA, 28, true, false, BaseColor.BLACK); pdfBuilder.addFont("CONTENT_PARAM", Font.FontFamily.HELVETICA, 16, false, false, BaseColor.BLACK); if (type.equals(this.getString(R.string.main_nav_mark_list))) { List<String> stringList = this.sqLite.listMarkLists(where); List<MarkListSettings> markListSettings = new LinkedList<>(); for (String string : stringList) { markListSettings.add(this.sqLite.getMarkList(string)); } pdfBuilder.addTitle(this.getString(R.string.main_nav_mark_list), "header", Paragraph.ALIGN_CENTER); for (MarkListSettings settings : markListSettings) { pdfBuilder = this.apiHelper.exportMarkListToPDF(pdfBuilder, settings); } pdfBuilder.close(); return true; } else if (type.equals(this.getString(R.string.main_nav_calculateMark))) { List<SchoolYear> schoolYears = this.sqLite.getSchoolYears(where); for (SchoolYear schoolYear : schoolYears) { pdfBuilder = apiHelper.exportMarkToPDF(pdfBuilder, schoolYear); } pdfBuilder.close(); return true; } else if (type.equals(this.getString(R.string.main_nav_timetable))) { List<TimeTable> timeTables = this.sqLite.getTimeTables(where); List<String> headers = Arrays.asList(this.getString(R.string.timetable_times), this.getString(R.string.timetable_days_mon), this.getString(R.string.timetable_days_tue), this.getString(R.string.timetable_days_wed), this.getString(R.string.timetable_days_thu), this.getString(R.string.timetable_days_fri), this.getString(R.string.timetable_days_sat), this.getString(R.string.timetable_days_sun)); for (TimeTable timeTable : timeTables) { pdfBuilder = this.apiHelper.exportTimeTableToPDF(pdfBuilder, timeTable, headers, this.sqLite); } pdfBuilder.close(); return true; } else if (type.equals(this.getString(R.string.main_nav_notes))) { for (Note note : this.sqLite.getNotes(where)) { pdfBuilder = this.apiHelper.exportNoteToPDF(pdfBuilder, note); } pdfBuilder.close(); return true; } else if (type.equals(this.getString(R.string.main_nav_todo))) { for (ToDoList toDoList : this.sqLite.getToDoLists(where)) { pdfBuilder = this.apiHelper.exportToDoListToPDF(pdfBuilder, toDoList); } pdfBuilder.close(); return true; } else if (type.equals(this.getString(R.string.main_nav_timer))) { for (TimerEvent timerEvent : this.sqLite.getTimerEvents(where)) { pdfBuilder = this.apiHelper.exportTimerEventToPDF(pdfBuilder, timerEvent); } pdfBuilder.close(); return true; } } catch (Exception ex) { Helper.printException(this.getApplicationContext(), ex); } return false; }
From source file:de.domjos.schooltools.core.utils.fileUtils.PDFBuilder.java
License:Open Source License
public void addFont(String key, Font.FontFamily fontFamily, float size) { this.addFont(key, fontFamily, size, false, false, BaseColor.BLACK); }
From source file:de.jost_net.JVerein.io.HeaderFooter.java
License:Open Source License
/** * Adds the header and the footer./*from w ww. j av a2s . c om*/ * */ @Override public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = document.getPageSize(); switch (writer.getPageNumber() % 2) { case 0: // ColumnText.showTextAligned(writer.getDirectContent(), // Element.ALIGN_RIGHT, header[0], rect.getRight(), rect.getTop(), 0); break; case 1: // ColumnText.showTextAligned(writer.getDirectContent(), // Element.ALIGN_LEFT, // header[1], rect.getLeft(), rect.getTop(), 0); break; } float left = rect.getLeft() + document.leftMargin(); float right = rect.getRight() - document.rightMargin(); float bottom = rect.getBottom() + document.bottomMargin(); PdfContentByte pc = writer.getDirectContent(); pc.setColorStroke(BaseColor.BLACK); pc.setLineWidth(0.5f); pc.moveTo(left, bottom - 5); pc.lineTo(right, bottom - 5); pc.stroke(); pc.moveTo(left, bottom - 25); pc.lineTo(right, bottom - 25); pc.stroke(); ColumnText.showTextAligned(pc, Element.ALIGN_CENTER, new Phrase(footer + " " + pagenumber, Reporter.getFreeSans(7)), (left + right) / 2, bottom - 18, 0); }
From source file:de.jost_net.JVerein.io.Reporter.java
License:Open Source License
/** * Erzeugt eine Zelle fuer die uebergebene Zahl. * // ww w .j av a 2 s. c om * @param value * die Zahl. * @return die erzeugte Zelle. */ private PdfPCell getDetailCell(double value) { Font f = null; if (value >= 0) { f = getFreeSans(8, BaseColor.BLACK); } else { f = getFreeSans(8, BaseColor.RED); } PdfPCell cell = new PdfPCell(new Phrase(Einstellungen.DECIMALFORMAT.format(value), f)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); return cell; }
From source file:digiho.DigiHoInitial1.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: jDate1.setText(""); Calendar timer = Calendar.getInstance(); timer.getTime();// w w w .j a v a 2 s .com SimpleDateFormat Tdate = new SimpleDateFormat("dd-MMM-yyy"); jDate1.setText(Tdate.format(timer.getTime())); Document doc = new Document(); try { PdfWriter.getInstance(doc, new FileOutputStream("f:\\DiGiho\\Complaint From\\" + jCustomer1.getText() + ".pdf")); doc.open(); doc.add(new Paragraph("\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); doc.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n")); doc.add(new Phrase("Customer ID.: ")); doc.add(new Phrase(jCustomer1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase(" Date: " + jDate1.getText() + " \n\n")); doc.add(new Phrase("Name: ")); doc.add(new Phrase(jName1.getText() + ". " + jName2.getText() + " " + jName3.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nFather's Name: ")); doc.add(new Phrase(jFatherName1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nAddress: ")); doc.add(new Phrase(jAddress1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nBlock: ")); doc.add(new Phrase(jBlock1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nCity: ")); doc.add(new Phrase(jCity1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nDistrict: ")); doc.add(new Phrase(jDistrict1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Phrase("\nMoblie No.: ")); doc.add(new Phrase(jMobile1.getText(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); doc.add(new Paragraph("\n\n\n\n\n\n")); doc.add(new Paragraph(" (1) " + jTextField2.getText())); doc.add(new Paragraph(" (2) " + jcomplain1.getText())); doc.add(new Paragraph(" (3) " + jcomplain3.getText())); doc.add(new Paragraph(" (4) " + jcomplain4.getText())); doc.close(); } catch (DocumentException e) { e.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(DigiHoInitial1.class.getName()).log(Level.SEVERE, null, ex); } JOptionPane.showMessageDialog(null, "File has been created", "deeps message", JOptionPane.WARNING_MESSAGE); }
From source file:direccion.GeneradorFormato.java
@Override public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); Image imghead = null;// w ww . j av a2s.c o m PdfContentByte cbhead = null; // try { // imghead = Image.getInstance("LogoSapito5.png"); // imghead.setAbsolutePosition(0, 0); // imghead.setAlignment(Image.ALIGN_CENTER); // imghead.scalePercent(10f); // cbhead = writer.getDirectContent(); // PdfTemplate tp = cbhead.createTemplate(100, 150); // tp.addImage(imghead); // cbhead.addTemplate(tp, 100, 715); // } catch (BadElementException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (DocumentException e) { // e.printStackTrace(); // } Phrase headPhraseImg = new Phrase(cbhead + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL)); Calendar c1 = Calendar.getInstance(); Calendar c2 = new GregorianCalendar(); String dia, mes, annio; dia = Integer.toString(c1.get(Calendar.DATE)); mes = Integer.toString(c1.get(Calendar.MONTH)); annio = Integer.toString(c1.get(Calendar.YEAR)); Date fecha = new Date(); String fechis = dia + "/" + mes + "/" + annio; Paragraph parrafo5 = new Paragraph(fechis, FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo5), rect.getRight(450), rect.getTop(-80), 0); Paragraph parrafo7 = new Paragraph("Empresa Sapito S.A. de C.V.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo7), rect.getBottom(250), rect.getTop(-60), 0); Paragraph parrafo8 = new Paragraph("Reporte algoooooo", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo8), rect.getBottom(250), rect.getTop(-40), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(650), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-24), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-20), 0); Paragraph parrafo6 = new Paragraph(String.format("Pg %d", writer.getPageNumber()), FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo6), rect.getRight(-35), rect.getTop(-80), 0); }
From source file:empguadalupe.Menu.Evaluacion.Menu.Resultado.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed FileOutputStream archivo = null; String nombrearchivo = NombreOP.getText() + "_" + CedulaOP.getText(); try {/* w ww. j a v a 2 s .c om*/ archivo = new FileOutputStream(nombrearchivo + ".pdf"); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(rootPane, "Cierre la ventana del PDF para poder crear uno nuevo"); return; } Document documento = new Document(); try { PdfWriter.getInstance(documento, archivo); } catch (DocumentException ex) { } documento.open(); try { Image foto = Image.getInstance("src\\imgfondo\\thumbGRUPO20EPM20CON20CIERRE202013.jpg"); foto.scaleToFit(150, 150); foto.setAlignment(Chunk.ALIGN_LEFT); documento.add(foto); } catch (Exception e) { e.printStackTrace(); } try { documento.add(new Paragraph("RESULTADOS EVALUACION GENERAL", FontFactory.getFont("arial", // fuente 27, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Nombre del Funcionario: " + NombreOP.getText() + "\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Cedula del Funcionario: " + CedulaOP.getText() + "\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Registro EPM del Funcionario: " + Registro.getText() + "\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Nombre del Gestor:" + NombreS.getText() + "\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n")); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("RESULTADOS ", FontFactory.getFont("arial", // fuente 17, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n" + "Arranque ", FontFactory.getFont("arial", // fuente 15, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Numero de Intentos Negativos: " + CalificacionA.getText() + " " + "Tiempo: " + tiempoA)); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n" + "Paro Normal ", FontFactory.getFont("arial", // fuente 15, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Numero de Intentos Negativos: " + CalificacionA1.getText() + " " + "Tiempo: " + tiempoA1)); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n" + "Paro Rapido ", FontFactory.getFont("arial", // fuente 15, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Numero de Intentos Negativos: " + CalificacionA2.getText() + " " + "Tiempo: " + tiempoA2)); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("\r\n\r\n" + "Paro de Emergencia ", FontFactory.getFont("arial", // fuente 15, // tamao Font.BOLD, BaseColor.BLACK))); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } try { documento.add(new Paragraph("Numero de Intentos Negativos: " + CalificacionA3.getText() + " " + "Tiempo:" + tiempoA3)); } catch (DocumentException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } documento.close(); File path = new File(nombrearchivo + ".pdf"); try { Desktop.getDesktop().open(path); } catch (IOException ex) { Logger.getLogger(Resultado.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:EplanPrinter.PDFPrint.java
License:Open Source License
public String insertStamp(String loc, float x, float y, int width, int height, int set, String date, int pageNum, int masterHeight, int masterWidth, String projNo) throws BadElementException, MalformedURLException, IOException, DocumentException { Image image = Image.getInstance(loc); float[] scalar = scale(x, y, width, height, masterHeight, masterWidth, pageNum); float[] trans = translate(x, y, r[pageNum - 1].getHeight(), r[pageNum - 1].getWidth(), masterHeight, masterWidth, pageNum);/*from w ww .j a va 2s . c o m*/ float[] f = commentTrans(x, y, masterHeight, masterWidth, pageNum); float shift = 0; /* Addition. ftorres - 7/22/2015 - Added to account for rotated pages * with the origin (0,0) not set to the bottom-left of the page. [1400] */ trans = translateRotation(trans[0], trans[1], pageNum); if (set == 1) { float m = image.getPlainHeight(); float pageChunk = r[pageNum - 1].getHeight() / 10; shift = r[pageNum - 1].getHeight() / 100; scalar[1] = (int) (pageChunk); scalar[0] = (int) (image.getPlainWidth() * pageChunk) / image.getPlainHeight(); trans[0] = (int) (0 + (pageChunk * widthScalar)); trans[1] = (int) (r[pageNum - 1].getHeight() - (pageChunk * heightScalar) - (shift * (heightScalar + 2))); heightScalar = heightScalar + 1; if (heightScalar == 8) { heightScalar = 0; widthScalar = widthScalar + 2; } } if (set == 1) { image.setAbsolutePosition(trans[0] + shift, trans[1] - scalar[1]); image.scaleAbsoluteHeight(scalar[1]); image.scaleAbsoluteWidth(scalar[0]); image.setRotationDegrees(rot); } else { //swap stamp dimensions for rotated drawings if (rot > 0) { image.setAbsolutePosition(trans[0] - 2 * scalar[1], trans[1] - 2 * scalar[0]); } else { image.setAbsolutePosition(trans[0], trans[1] - 2 * scalar[1]); } image.scaleAbsoluteHeight(scalar[1] * 2); image.scaleAbsoluteWidth(scalar[0] * 2); image.setRotationDegrees(rot); } PdfContentByte fg = pds.getOverContent(pageNum); fg.addImage(image); //Added by tmittelstadt on 09/21/2012 for ticket #698 //draws a box around the date fg.setColorFill(BaseColor.WHITE); fg.setLineWidth(0f); //dmoody removed box. ticket 900 /*fg.moveTo(trans[0], trans[1] - scalar[1] * 2); fg.lineTo(trans[0], trans[1] - scalar[1] * 2 - 10); fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2 - 10); fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2); fg.lineTo(trans[0], trans[1] - scalar[1] * 2);*/ fg.closePathFillStroke(); fg.fill(); //adds the date the stamp was added to the document to the pdf Phrase p = new Phrase(date); p.getFont().setColor(BaseColor.BLACK); //Modification zreeve 10/11/2012. set font size to 11. p.getFont().setSize(9f); //p.getChunks().get(0).setAnnotation(PdfAnnotation.createText(pds.getWriter(), new Rectangle(trans[0],trans[1], trans[0]+5f, trans[1]+5f), id, comment, true, id)); ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, p, (float) (trans[0]), (float) (trans[1] - scalar[1] * 2 - 12), 0); Phrase pn = new Phrase("#[" + projNo + "]"); pn.getFont().setColor(BaseColor.BLACK); pn.getFont().setSize(10f); pn.getFont().setStyle("bold"); ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, pn, (float) (trans[0]), (float) (trans[1] - scalar[1] * 2 - 22), 0); return ""; }
From source file:Export.ReciboPagamento.java
/** * new Documento Pagamento// w w w.ja v a 2s . c om * * @param Prestacao * @param user * @return String */ public String criarDoc(Integer Prestacao, String user) { try { SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); numPrestacao = Prestacao; File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Recebimento " + Ddata + ".pdf"); OutputStream outputStraem = new FileOutputStream(ff); reString = "../Documentos/" + user + "/Pagamentos/" + "Recebimento " + Ddata + ".pdf"; Document document = new Document(PageSize.A4); document.setMargins(20f, 20f, 0f, 0f); PdfWriter writer = PdfWriter.getInstance(document, outputStraem); Font fontTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 17f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontTitileShort = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontRecibo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontReciboTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f, Font.NORMAL, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.NORMAL, BaseColor.BLUE.darker().darker()); Font fontConteudoTxt = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudoTxtUl = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f, Font.ITALIC + Font.UNDERLINE, BaseColor.BLACK.darker().darker().darker()); MyFooter event = new MyFooter(); writer.setPageEvent(event); daoRecibo r = new daoRecibo(); HashMap<String, Object> map = r.getDados(); document.open(); PdfPTable table = detaDoc(map, fontTitile, fontRecibo, fontTitileShort, fontReciboTxt, fontConteudo, fontConteudoTxt, fontConteudoTxtUl); // document.add(table); // document.add(new Paragraph("\n\n\n\n\n\n\n\n\n", fontTitileShort)); // document.add(table); // document.newPage(); table.setTotalWidth(555); table.writeSelectedRows(-1, 100, 22.5f, 820f, writer.getDirectContent()); table.writeSelectedRows(-1, 100, 22.5f, 400f, writer.getDirectContent()); // table.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); document.close(); return reString; } catch (DocumentException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); return reString; } catch (FileNotFoundException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.ReciboPagamento.java
public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort, Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl) throws DocumentException { PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 }); try {/*w w w . j a v a 2 s.com*/ pTablePrincipal.setWidthPercentage(100f); PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 }); pTableTitulo.setWidthPercentage(100); PdfPTable pTableTituloImage = new PdfPTable(new float[] { 20, 80 }); pTableTituloImage.setWidthPercentage(100); PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingTop(20f); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo)); cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM); cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setPaddingLeft(70f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setVerticalAlignment(Element.ALIGN_TOP); cellTitulo.setPaddingBottom(30f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); imageEmpresa.setAlignment(Image.ALIGN_CENTER); PdfPCell cellImagem = new PdfPCell(imageEmpresa); cellImagem.setBorder(PdfPCell.NO_BORDER); cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo); cellpTableTitulo.setBorder(PdfPCell.NO_BORDER); cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableTituloImage.addCell(cellImagem); pTableTituloImage.addCell(cellpTableTitulo); PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage); cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellpTableTituloPrincipal); PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f }); pTableDataCaixaMontante.setWidthPercentage(100f); PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); cellDataCaixaMontante.setBorder(0); Paragraph p = new Paragraph(); p.add(new Phrase("Data: ".toUpperCase(), fontRecibo)); p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt)); p.setAlignment(Element.ALIGN_RIGHT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingBottom(5f); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo)); p.add(new Phrase("So Tom", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo)); Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO))); // SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:"); Object dRegistro = map.get(DATAREGAPOLICE); montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante); cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellDataCaixaMontantePrincipal); PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 }); pTableConteudo.setWidthPercentage(100f); PdfPCell cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); Paragraph pConteudo = new Paragraph(); pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt)); /** * For alter */ pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("FGA: ", fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo)); pConteudo.add( new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt)); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); pConteudo = new Paragraph(); pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt)); PdfPTable pTableNomeCod = new PdfPTable(new float[] { 70, 30 }); pTableNomeCod.setWidthPercentage(100); Paragraph pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt)); PdfPCell cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pConteudo.add(pTableNomeCod); JTextPane jtp = new JTextPane(); Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + "")); valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); Moeda.EscreverEstenso(valor, jtp, "Dobras"); pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt)); PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 }); pTableApoliceDatasP.setWidthPercentage(100); PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 }); pTableApoliceDatas.setWidthPercentage(100); for (int i = 0; i < 1; i++) { PdfPCell cellApolice = new PdfPCell(); Paragraph pApolice = new Paragraph(); pApolice.add(new Phrase("N ", fontConteudo)); pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt)); cellApolice.addElement(pApolice); cellApolice.setPaddingTop(-2f); cellApolice.setPaddingBottom(2f); cellApolice.setBorder(0); pTableApoliceDatas.addCell(cellApolice); PdfPCell cellDatas = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt)); cellDatas.addElement(pDatas); cellDatas.setBorder(0); cellDatas.setPaddingTop(-2f); cellDatas.setPaddingBottom(2f); pTableApoliceDatas.addCell(cellDatas); } PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo)); cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); cellApoliceP = new PdfPCell(pTableApoliceDatas); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); pConteudo.add(pTableApoliceDatasP); // PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f }); pTableTipoPagemento.setWidthPercentage(100f); PdfPCell cellTipoPageme = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); cellTipoPageme = new PdfPCell(); pDatas = new Paragraph(); pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); pConteudo.add(pTableTipoPagemento); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo)); cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellConteudoPrincipal); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); pTableAssinatura.setWidthPercentage(100f); Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker()); PdfPCell cellAcessorio = new PdfPCell(); Paragraph pAcessorio = new Paragraph(); pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess)); pAcessorio.add(new Phrase( (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "), fontConteudoTxt_acess)); cellAcessorio.addElement(pAcessorio); cellAcessorio.setColspan(2); cellAcessorio.setBorder(0); cellAcessorio.setPaddingBottom(4f); cellAcessorio.setPaddingTop(-2f); pTableAssinatura.addCell(cellAcessorio); PdfPCell cellLinhaAssina = new PdfPCell(); Paragraph pAssinatura = new Paragraph(); pAssinatura.add(new Paragraph("_________________________________", fontConteudo)); pAssinatura.add(new Paragraph(" Carimbo e Assinatura", fontConteudo)); pAssinatura.setAlignment(Element.ALIGN_CENTER); cellLinhaAssina.addElement(pAssinatura); cellLinhaAssina.setPaddingBottom(2f); cellLinhaAssina.setBorder(0); cellLinhaAssina.setPaddingTop(25f); pTableAssinatura.addCell(cellLinhaAssina); PdfPCell cellCambio = new PdfPCell(); Paragraph pCombio = new Paragraph(); pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt)); pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt)); cellCambio.addElement(pCombio); cellCambio.setBorder(0); cellCambio.setPaddingTop(-2f); cellCambio.setPaddingBottom(2f); pTableAssinatura.addCell(cellCambio); PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura); cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal)); // pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent()); // pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); } catch (BadElementException | IOException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return pTablePrincipal; }