List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:com.dlya.facturews.DlyaPdfExporter2.java
License:Open Source License
protected void writePageAnchor(int pageIndex) throws DocumentException { Map<Attribute, Object> attributes = new HashMap<Attribute, Object>(); FontUtil.getInstance(jasperReportsContext).getAttributesWithoutAwtFont(attributes, new JRBasePrintText(jasperPrint.getDefaultStyleProvider())); Font pdfFont = getFont(attributes, getLocale(), false); Chunk chunk = new Chunk(" ", pdfFont); chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1)); //tagHelper.startPageAnchor(); ColumnText colText = new ColumnText(pdfContentByte); colText.setSimpleColumn(new Phrase(chunk), 0, jasperPrint.getPageHeight(), 1, 1, 0, Element.ALIGN_LEFT); colText.go();/*from w ww . ja v a2 s.c om*/ //tagHelper.endPageAnchor(); }
From source file:com.dlya.facturews.DlyaPdfExporter2.java
License:Open Source License
/** * *//*w ww. j a v a 2s .c o m*/ protected Chunk getChunk(Map<Attribute, Object> attributes, String text, Locale locale) { // underline and strikethrough are set on the chunk below Font font = getFont(attributes, locale, false); Chunk chunk = new Chunk(text, font); if (hasUnderline(attributes)) { // using the same values as sun.font.Fond2D chunk.setUnderline(null, 0, 1f / 18, 0, -1f / 12, 0); } if (hasStrikethrough(attributes)) { // using the same thickness as sun.font.Fond2D. // the position is calculated in Fond2D based on the ascent, defaulting // to iText default position which depends on the font size chunk.setUnderline(null, 0, 1f / 18, 0, 1f / 3, 0); } Color backcolor = (Color) attributes.get(TextAttribute.BACKGROUND); if (backcolor != null) { chunk.setBackground(backcolor); } Object script = attributes.get(TextAttribute.SUPERSCRIPT); if (script != null) { if (TextAttribute.SUPERSCRIPT_SUPER.equals(script)) { chunk.setTextRise(font.getCalculatedSize() / 2); } else if (TextAttribute.SUPERSCRIPT_SUB.equals(script)) { chunk.setTextRise(-font.getCalculatedSize() / 2); } } if (splitCharacter != null) { //TODO use line break offsets if available? chunk.setSplitCharacter(splitCharacter); } return chunk; }
From source file:com.ev.export.AnnualPDFExporter.java
License:Apache License
private void addTableHeadCell(String heading) throws Exception { Chunk chunk = new Chunk(heading, TABLE_HEAD_FONT); Cell cell = new Cell(chunk); table.addCell(cell);/*from w ww . j av a 2 s .c o m*/ }
From source file:com.geek.tutorial.itext.text.Chunk_Example.java
License:Open Source License
public Chunk_Example() throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("chunk_example.pdf")); document.open();/*from w w w .jav a2 s.c o m*/ Font font = new Font(Font.COURIER, 10, Font.BOLD); // 1 font.setColor(new Color(0x92, 0x90, 0x83)); Chunk chunk = new Chunk("testing text element", font); // 2 chunk.setBackground(new Color(0xff, 0xe4, 0x00)); // 3 document.add(chunk); // 4 document.close(); }
From source file:com.geek.tutorial.itext.text.Paragraph_Example.java
License:Open Source License
public Paragraph_Example() throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("paragraph_example.pdf")); document.open();//from w w w. j a v a2s . c om Font font = new Font(Font.COURIER, 10, Font.BOLD); font.setColor(new Color(0x92, 0x90, 0x83)); Chunk chunk = new Chunk("testing text element ", font); chunk.setBackground(new Color(0xff, 0xe4, 0x00)); Phrase phrase = new Phrase(20, "This is initial text. "); for (int i = 0; i < 10; i++) { phrase.add(chunk); } Paragraph paragraph = new Paragraph(); // 1 paragraph.add(phrase); // 2 document.add(paragraph); // 3 document.add(paragraph); // 4 document.close(); }
From source file:com.geek.tutorial.itext.text.Phrase_Example.java
License:Open Source License
public Phrase_Example() throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("phrase_example.pdf")); document.open();/* www . j a v a 2s. c om*/ Font font = new Font(Font.COURIER, 10, Font.BOLD); font.setColor(new Color(0x92, 0x90, 0x83)); Chunk chunk = new Chunk("testing text element ", font); chunk.setBackground(new Color(0xff, 0xe4, 0x00)); Phrase phrase = new Phrase(20, "This is initial text. "); // 1 for (int i = 0; i < 10; i++) { phrase.add(chunk); // 2 } document.add(phrase); // 3 document.close(); }
From source file:com.gp.cong.logisoft.reports.BookingCoverSheetPdfCreater.java
public Paragraph getContainers(String simpleRequest, SearchBookingReportDTO searchBookingReportDTO, MessageResources messageResources) { if (simpleRequest.equals("simpleRequest")) { Paragraph bkgParagraph1 = new Paragraph(); List chargesList = searchBookingReportDTO.getChargesList(); BookingfclUnits bookingfclUnits = new BookingfclUnits(); String container = ""; Map<String, String> summaryMap = new HashMap<String, String>(); if (chargesList != null && chargesList.size() > 0) { boolean isFirst = true; for (int i = 0; i < chargesList.size(); i++) { bookingfclUnits = (BookingfclUnits) chargesList.get(i); if (bookingfclUnits.getApproveBl() != null && bookingfclUnits.getApproveBl().equalsIgnoreCase("Yes")) { if (bookingfclUnits.getPrint() != null && !bookingfclUnits.getPrint().equalsIgnoreCase("on")) { String temp = bookingfclUnits.getUnitType().getCodedesc().toString() + "-" + bookingfclUnits.getSpecialEquipmentUnit() + "-" + bookingfclUnits.getStandardCharge(); String newTemp = bookingfclUnits.getUnitType().getCodedesc(); if (null == summaryMap.get(temp)) { String tempArray[] = newTemp.split("="); // if (!isFirst) { // bkgParagraph1.add(new Phrase(" \n")); // } if (tempArray[1].equalsIgnoreCase(messageResources.getMessage("container40HC"))) { container = bookingfclUnits.getNumbers() + " X " + "40" + "'" + "HC "; bkgParagraph1.add(new Chunk(container, blackBoldFont2)); if ("Y".equalsIgnoreCase(bookingfclUnits.getOutOfGauge())) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1.add(new Chunk(OUT_OF_GAUGE, GreenFont8)); }/* www . j a v a 2 s . c o m*/ if (null != bookingfclUnits.getSpecialEquipment() && !bookingfclUnits.getSpecialEquipment().equals("")) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1 .add(new Chunk(bookingfclUnits.getSpecialEquipment(), GreenFont8)); } isFirst = false; } else if (tempArray[1] .equalsIgnoreCase(messageResources.getMessage("container40NOR"))) { container = bookingfclUnits.getNumbers() + " X " + "40" + "'" + "NOR "; bkgParagraph1.add(new Chunk(container, blackBoldFont2)); if ("Y".equalsIgnoreCase(bookingfclUnits.getOutOfGauge())) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1.add(new Chunk(OUT_OF_GAUGE, GreenFont8)); } if (null != bookingfclUnits.getSpecialEquipment() && !bookingfclUnits.getSpecialEquipment().equals("")) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1 .add(new Chunk(bookingfclUnits.getSpecialEquipment(), GreenFont8)); } isFirst = false; } else { container = bookingfclUnits.getNumbers() + " X " + tempArray[1] + "' "; bkgParagraph1.add(new Chunk(container, blackBoldFont2)); if ("Y".equalsIgnoreCase(bookingfclUnits.getOutOfGauge())) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1.add(new Chunk(OUT_OF_GAUGE, GreenFont8)); } if (null != bookingfclUnits.getSpecialEquipment() && !bookingfclUnits.getSpecialEquipment().equals("")) { bkgParagraph1.add(new Phrase(", ")); bkgParagraph1 .add(new Chunk(bookingfclUnits.getSpecialEquipment(), GreenFont8)); } isFirst = false; } } summaryMap.put(temp, temp); } } } } return (bkgParagraph1); } return new Paragraph(); }
From source file:com.ideaspymes.proyecttemplate.stock.web.ProductoConsultaBean.java
public String createPdf() throws IOException, DocumentException { EtiquetaConf conf = etiquetaConfDAO.getEtiquetaConfDefault(); if (hayParaImprimir() && conf != null) { HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance() .getExternalContext().getResponse(); response.setContentType("application/x-pdf"); response.setHeader("Content-Disposition", "attachment; filename=\"etiquetas.pdf\""); float ancho = Utilities.millimetersToPoints(conf.getAnchoHoja().floatValue()); System.out.println("Ancho: " + ancho); float largo = Utilities.millimetersToPoints(conf.getLargoHoja().floatValue()); System.out.println("Alto: " + largo); // step 1 Document document = new Document(new Rectangle(ancho, largo)); // step 2 document.setMargins(0f, 0f, 0f, 0f); PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // step 3 document.open();/* w w w.ja v a 2s . c o m*/ // step 4 PdfContentByte cb = writer.getDirectContent(); for (Producto p : getLista()) { if (p.getCantidadEtiquetas() > 0) { PdfPTable table = new PdfPTable(2); table.setWidthPercentage(96); Font fontbold = FontFactory.getFont("Times-Roman", 8, Font.NORMAL); Chunk productTitle = new Chunk("HC", fontbold); Paragraph pTitile = new Paragraph(productTitle); pTitile.setAlignment(Element.ALIGN_LEFT); pTitile.setLeading(6, 0); PdfPCell cellTitle = new PdfPCell(); cellTitle.setHorizontalAlignment(Element.ALIGN_LEFT); cellTitle.setVerticalAlignment(Element.ALIGN_TOP); cellTitle.setBorder(Rectangle.NO_BORDER); cellTitle.addElement(pTitile); Font font2 = FontFactory.getFont("Times-Roman", conf.getTamDescripcion().floatValue(), Font.NORMAL); Chunk productName = new Chunk(p.getNombre(), font2); Paragraph pName = new Paragraph(productName); pName.setAlignment(Element.ALIGN_CENTER); //pTitile.setLeading(0, 1); cellTitle.addElement(pName); table.addCell(cellTitle); Barcode39 code39 = new Barcode39(); code39.setCode(p.getCodigo()); //code39.setCodeType(Barcode.EAN13); code39.setBarHeight(conf.getAltoCodBarra().floatValue()); //codeEan.setX(0.7f); code39.setSize(conf.getTamDescripcion().floatValue()); //code39.setAltText("HC - " + p.getNombre()); PdfPCell cellBarcode = new PdfPCell(); cellBarcode.setHorizontalAlignment(Element.ALIGN_CENTER); cellBarcode.setBorder(Rectangle.NO_BORDER); cellBarcode.addElement(code39.createImageWithBarcode(cb, null, Color.BLACK)); table.addCell(cellBarcode); for (int i = 0; i < p.getCantidadEtiquetas(); i++) { document.add(table); document.newPage(); } } } // step 5 document.close(); response.getOutputStream().flush(); response.getOutputStream().close(); FacesContext.getCurrentInstance().responseComplete(); } else { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "No hay nada que imprimir", "")); } return null; }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeEntry(Document document, String label, String value) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.setIndentationLeft(18); questionParagraph.add(new Chunk(label.trim() + ": ", boldedFont)); questionParagraph.add(new Chunk(value == null ? "" : value.trim(), normalFont)); document.add(questionParagraph);/*from ww w.ja v a2s . com*/ }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeEntry(Document document, String label) throws Exception { Paragraph questionParagraph = new Paragraph(); questionParagraph.setLeading(14, 0); questionParagraph.setIndentationLeft(18); questionParagraph.add(new Chunk(label.trim(), boldedFont)); document.add(questionParagraph);/* w w w . ja va 2 s . c o m*/ }