List of usage examples for com.lowagie.text Paragraph add
public boolean add(Object o)
Object
to the Paragraph
. From source file:storemanagment.Printing.java
public PdfPCell createTextCellNormalUnderlined(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); // p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,16,java.awt.Font.BOLD)); // p.setFont(Font.BOLD); p.setAlignment(Element.ALIGN_CENTER); p.add(text); cell.addElement(p);// w w w . ja va 2 s . c o m cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }
From source file:storemanagment.Printing.java
public PdfPCell createTextCellcolor(String text, int c) { PdfPCell cell = new PdfPCell(); if (c % 2 == 0) { Paragraph p = new Paragraph(); cell.setBackgroundColor(Color.CYAN); p.add(text); cell.addElement(p);//w ww . j av a 2s .co m } else { Paragraph p = new Paragraph(); //cell.setBackgroundColor(Color.CYAN); p.add(text); cell.addElement(p); } return cell; }
From source file:subcentro_licto.presentacion.beans.DatosBuscadorBean.java
public void imprimirDatos() { //DateFormat dfDateFull = DateFormat.getDateInstance(DateFormat.FULL); try {//w w w . j a va2s. c om //Generamos el archivo PDF String directorioArchivos; ServletContext ctx = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); directorioArchivos = ctx.getRealPath("/") + "reports"; String name = directorioArchivos + "/documento-datos.pdf"; Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(name)); //PdfWriter writer = PdfWriter.getInstance(document, //new FileOutputStream("C:")); Paragraph paragraph = new Paragraph(); PdfPTable table = new PdfPTable(2); PdfPTable table1 = new PdfPTable(2); PdfPTable table2 = new PdfPTable(2); PdfPTable table3 = new PdfPTable(2); PdfPTable table4 = new PdfPTable(2); PdfPTable table5 = new PdfPTable(2); PdfPTable table6 = new PdfPTable(2); PdfPTable table7 = new PdfPTable(2); PdfPTable table8 = new PdfPTable(2); PdfPTable table9 = new PdfPTable(2); PdfPTable table10 = new PdfPTable(2); PdfPTable table11 = new PdfPTable(2); PdfPTable table12 = new PdfPTable(2); PdfPTable table13 = new PdfPTable(1); paragraph.add("\n\n\n\n\n\n"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); document.open(); Image image1 = Image.getInstance( "C:/Users/Usuario/Documents/NetBeansProjects/gestionsalud/web/resources/images/logoMSP.jpg"); image1.setAlignment(Element.ALIGN_CENTER); PdfPCell cell5 = new PdfPCell(new Paragraph("Fecha Agresin: " + datosSel.getFecha_agresion())); PdfPCell cell7 = new PdfPCell(new Paragraph("Fecha Atencin: " + datosSel.getFecha_de_atencion())); PdfPCell cell8 = new PdfPCell(new Paragraph("Nombres: " + datosSel.getNombres())); PdfPCell cell11 = new PdfPCell(new Paragraph("Apellidos: " + datosSel.getApellidos())); PdfPCell cell12 = new PdfPCell(new Paragraph("Edad: " + datosSel.getEdad())); PdfPCell cell9 = new PdfPCell(new Paragraph("Sexo: " + datosSel.getSexo())); PdfPCell cell10 = new PdfPCell(new Paragraph("Estado Civil:" + datosSel.getEstado_civil())); PdfPCell cell13 = new PdfPCell(new Paragraph("Instruccin:" + datosSel.getInstruccion_formal())); PdfPCell cell1 = new PdfPCell(new Paragraph("Ocupacin: " + datosSel.getOcupacion())); PdfPCell cell2 = new PdfPCell(new Paragraph("Institucin: " + datosSel.getInstitucion())); PdfPCell cell3 = new PdfPCell(new Paragraph("Asociacin: " + datosSel.getAsociacion())); PdfPCell cell4 = new PdfPCell(new Paragraph("Provincia: " + datosSel.getProvincia())); PdfPCell cell6 = new PdfPCell(new Paragraph("Cantn: " + datosSel.getCanton_domicilio())); PdfPCell cell14 = new PdfPCell(new Paragraph("Parroquia: " + datosSel.getParroquia_domicilio())); PdfPCell cell15 = new PdfPCell(new Paragraph("Barrio: " + datosSel.getBarrio())); PdfPCell cell16 = new PdfPCell(new Paragraph("Calles: " + datosSel.getCalles_domicilio())); PdfPCell cell17 = new PdfPCell(new Paragraph("Direccin Trabajo: " + datosSel.getDireccion_trabajo())); PdfPCell cell18 = new PdfPCell(new Paragraph("Telfono Domicilio: " + datosSel.getTelefono())); PdfPCell cell19 = new PdfPCell(new Paragraph("Telfono Trabajo: " + datosSel.getTelefono_trabajo())); PdfPCell cell20 = new PdfPCell( new Paragraph("Objeto de Agresin: " + datosSel.getObjeto_de_agresion())); PdfPCell cell21 = new PdfPCell( new Paragraph("Tipo de Agresin: " + datosSel.getTipos_de_agresiones())); PdfPCell cell22 = new PdfPCell( new Paragraph("Estado de Conciencia: " + datosSel.getEstado_de_conciencia())); PdfPCell cell23 = new PdfPCell(new Paragraph("Lugar de Agresin: " + datosSel.getLugar_de_agresion())); PdfPCell cell24 = new PdfPCell(new Paragraph("Frecuencia: " + datosSel.getFrecuencia())); PdfPCell cell25 = new PdfPCell(new Paragraph("Caso Medico: " + datosSel.getCaso_medico())); PdfPCell cell26 = new PdfPCell(new Paragraph("Tratamiento: " + datosSel.getTratamiento())); PdfPCell cell27 = new PdfPCell(new Paragraph("Referido: " + datosSel.getReferido())); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); cell2.setHorizontalAlignment(Element.ALIGN_LEFT); cell3.setHorizontalAlignment(Element.ALIGN_LEFT); cell4.setHorizontalAlignment(Element.ALIGN_LEFT); cell5.setHorizontalAlignment(Element.ALIGN_LEFT); cell6.setHorizontalAlignment(Element.ALIGN_LEFT); cell7.setHorizontalAlignment(Element.ALIGN_LEFT); cell8.setHorizontalAlignment(Element.ALIGN_LEFT); cell9.setHorizontalAlignment(Element.ALIGN_LEFT); cell10.setHorizontalAlignment(Element.ALIGN_LEFT); cell11.setHorizontalAlignment(Element.ALIGN_LEFT); cell12.setHorizontalAlignment(Element.ALIGN_LEFT); cell13.setHorizontalAlignment(Element.ALIGN_LEFT); cell14.setHorizontalAlignment(Element.ALIGN_LEFT); cell15.setHorizontalAlignment(Element.ALIGN_LEFT); cell16.setHorizontalAlignment(Element.ALIGN_LEFT); cell17.setHorizontalAlignment(Element.ALIGN_LEFT); cell18.setHorizontalAlignment(Element.ALIGN_LEFT); cell19.setHorizontalAlignment(Element.ALIGN_LEFT); cell20.setHorizontalAlignment(Element.ALIGN_LEFT); cell21.setHorizontalAlignment(Element.ALIGN_LEFT); cell22.setHorizontalAlignment(Element.ALIGN_LEFT); cell23.setHorizontalAlignment(Element.ALIGN_LEFT); cell24.setHorizontalAlignment(Element.ALIGN_LEFT); cell25.setHorizontalAlignment(Element.ALIGN_LEFT); cell26.setHorizontalAlignment(Element.ALIGN_LEFT); cell27.setHorizontalAlignment(Element.ALIGN_LEFT); cell1.setBorder(Rectangle.NO_BORDER); cell2.setBorder(Rectangle.NO_BORDER); cell3.setBorder(Rectangle.NO_BORDER); cell4.setBorder(Rectangle.NO_BORDER); cell5.setBorder(Rectangle.NO_BORDER); cell6.setBorder(Rectangle.NO_BORDER); cell7.setBorder(Rectangle.NO_BORDER); cell8.setBorder(Rectangle.NO_BORDER); cell9.setBorder(Rectangle.NO_BORDER); cell10.setBorder(Rectangle.NO_BORDER); cell11.setBorder(Rectangle.NO_BORDER); cell12.setBorder(Rectangle.NO_BORDER); cell13.setBorder(Rectangle.NO_BORDER); cell14.setBorder(Rectangle.NO_BORDER); cell15.setBorder(Rectangle.NO_BORDER); cell16.setBorder(Rectangle.NO_BORDER); cell17.setBorder(Rectangle.NO_BORDER); cell18.setBorder(Rectangle.NO_BORDER); cell19.setBorder(Rectangle.NO_BORDER); cell20.setBorder(Rectangle.NO_BORDER); cell21.setBorder(Rectangle.NO_BORDER); cell22.setBorder(Rectangle.NO_BORDER); cell23.setBorder(Rectangle.NO_BORDER); cell24.setBorder(Rectangle.NO_BORDER); cell25.setBorder(Rectangle.NO_BORDER); cell26.setBorder(Rectangle.NO_BORDER); cell27.setBorder(Rectangle.NO_BORDER); table1.addCell(cell5); table1.addCell(cell7); table2.addCell(cell8); table2.addCell(cell11); table3.addCell(cell12); table3.addCell(cell9); table.addCell(cell10); table.addCell(cell13); table4.addCell(cell1); table4.addCell(cell2); table5.addCell(cell3); table5.addCell(cell4); table6.addCell(cell6); table6.addCell(cell14); table7.addCell(cell15); table7.addCell(cell16); table8.addCell(cell17); table8.addCell(cell18); table9.addCell(cell19); table9.addCell(cell20); table10.addCell(cell21); table10.addCell(cell22); table11.addCell(cell23); table11.addCell(cell24); table12.addCell(cell25); table12.addCell(cell26); table13.addCell(cell27); document.add(image1); document.add(paragraph); document.add(table1); document.add(table2); document.add(table3); document.add(table); document.add(table4); document.add(table5); document.add(table6); document.add(table7); document.add(table8); document.add(table9); document.add(table10); document.add(table11); document.add(table12); document.add(table13); //document.add(table); //document.setFooter(event); document.close(); //---------------------------- //Abrimos el archivo PDF FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); response.setContentType("application/pdf"); response.setHeader("Content-disposition", "inline=filename=" + name); try { response.getOutputStream().write(Util.getBytesFromFile(new File(name))); response.getOutputStream().flush(); response.getOutputStream().close(); context.responseComplete(); } catch (IOException e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:textdisplay.TagFilter.java
License:Educational Community License
public void replaceTagsWithPDFEncoding(String[] tags, styles[] tagStyles, OutputStream os) throws DocumentException { // FileWriter w = null; try {//from w w w . j a va 2 s. c o m BaseFont bf = BaseFont.createFont("/usr/Junicode.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Document doc = new Document(); PdfWriter p = PdfWriter.getInstance(doc, os); doc.open(); Paragraph para = new Paragraph(); para.setFont(new Font(bf, 12, Font.NORMAL)); //doc.add(para); Font italic = new Font(bf, 12, Font.ITALIC); Font bold = new Font(bf, 12, Font.BOLD); Font underlined = new Font(bf, 12, Font.UNDERLINE); StringBuilder chunkBuffer = new StringBuilder(""); //holds the next bit of content that will be added to the pdf as a chunk styles chunkStyle = null; //the style to be applied to chunkBuffer when it gets added to the document String chunkTag = ""; Stack<String> wrappingTags = new Stack(); Stack<styles> wrappingStyles = new Stack(); String content = text; Boolean inTag = false; //is this inside a tag, meaning between the < and > String tagTextBuffer = ""; //the text of the tag, including name and any parameters Boolean beingTagged = false; //Is the parser currently reading character data that is surrounded by a tag that demands styling for (int charCounter = 0; charCounter < this.text.length(); charCounter++) { if (text.charAt(charCounter) == '>') { inTag = false; //if this was a self closing tag, dont do anything if (tagTextBuffer.contains("/>")) { tagTextBuffer = ""; } else { //this is a closing tag, save the chunk and pop the tag and style off of the stack if (tagTextBuffer.startsWith("/")) { if (chunkStyle != null) System.out.print(" closing tag " + tagTextBuffer + " with style " + chunkStyle.name() + "\n"); else System.out.print(" closing tag " + tagTextBuffer + " with style null" + "\n"); if (chunkStyle == styles.paragraph) chunkBuffer = new StringBuilder("\n" + chunkBuffer); Chunk c = new Chunk(chunkBuffer.toString()); styleChunk(c, chunkStyle); if (chunkStyle != styles.remove) para.add(c); chunkBuffer = new StringBuilder(""); chunkStyle = null; chunkTag = ""; if (!wrappingStyles.empty()) { chunkStyle = wrappingStyles.pop(); chunkTag = wrappingTags.pop(); } tagTextBuffer = ""; } else { //this is the closing bracket of an opening tag String tagName = tagTextBuffer.split(" ")[0]; System.out.print("tag is " + tagName + "\n"); for (int i = 0; i < tags.length; i++) { if (tags[i].compareTo(tagName) == 0) { // this is a tag that is suposed to be styled in the pdf if (chunkStyle != null) { //this tag is nested in a tag that was already applying styling. Add this chunk to the pdf and put the tag/style //for the previous tag on the stack, so when this new tag ends, the previous styling will resume. if (chunkStyle == styles.paragraph) chunkBuffer = new StringBuilder("\n" + chunkBuffer); Chunk c = new Chunk(chunkBuffer.toString()); styleChunk(c, chunkStyle); if (chunkStyle != styles.remove) para.add(c); wrappingStyles.add(chunkStyle); wrappingTags.add(chunkTag); chunkTag = tagName; chunkStyle = tagStyles[i]; chunkBuffer = new StringBuilder(""); } else { Chunk c = new Chunk(chunkBuffer.toString()); para.add(c); chunkTag = tagName; chunkStyle = tagStyles[i]; chunkBuffer = new StringBuilder(""); } } } tagTextBuffer = ""; } } } if (inTag) { tagTextBuffer += text.charAt(charCounter); } if (text.charAt(charCounter) == '<') { if (inTag) { //if we hit another < before hitting a > this was not a tag, so add the tagTextBuffer to the chunk. It was simply conent. chunkBuffer.append(tagTextBuffer); tagTextBuffer = ""; } inTag = true; } if (!inTag && text.charAt(charCounter) != '>') { chunkBuffer.append(text.charAt(charCounter)); } } Chunk c = new Chunk(chunkBuffer.toString()); para.add(c); doc.newPage(); doc.add(para); doc.newPage(); doc.close(); } catch (IOException ex) { Logger.getLogger(TagFilter.class.getName()).log(Level.SEVERE, null, ex); } finally { } }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createSpeakerNotes4PerPage(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612//from w w w . j av a2 s .co m //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); PdfPTable table; PdfPCell cell; int entryCount = 0; int entryOnPage = 0; int currentIndex = VUE.getActivePathway().getIndex(); VUE.getActivePathway().setIndex(-1); for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) { final LWSlide slide = entry.produceSlide(); final LWComponent toDraw = (slide == null ? entry.node : slide); final String notes = entry.getNotes(); entryCount++; table = new PdfPTable(new float[] { 1, 1 }); table.getDefaultCell().setBorder(0); //table.getDefaultCell().setPaddingBottom(50.0f); table.setSpacingAfter(20.0f); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); Phrase phrase = new Phrase(notes); Font f = phrase.getFont(); f.setSize(8.0f); p.setFont(f); cell = new PdfPCell(phrase); cell.setBorder(0); PdfPCell i2 = new PdfPCell(); i2.setFixedHeight(172); i2.setBorder(0); //Render the table then throw the images on PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY); Point2D.Float offset = new Point2D.Float(); // center vertically only if landscape mode //if (format.getOrientation() == PageFormat.LANDSCAPE) //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit) Rectangle2D bounds = null; //if (!entry.isMapView()) bounds = slide.getBounds(); //else //bounds = entry.getFocal().getBounds(); Dimension page = null; page = new Dimension(SlideSizeX, 172); //PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80); double scale = ZoomTool.computeZoomFit(page, 5, bounds, offset, true); PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(), false, 60.0f); DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle entry.isMapView() ? entry.getFocal() : slide, false); // todo: absolute links shouldn't be spec'd here dc.setClipOptimized(false); dc.setPrintQuality(); /*if (!entry.isMapView()) slide.drawZero(dc); else { entry.getFocal().draw(dc); }*/ toDraw.drawFit(dc, 0); g2d.dispose(); //document.add(Image.getInstance(tp)); // int position = cell. // drawSequenceNumber(writer,36,position+203,entryCount); // cb.addTemplate(tp,56, position); Image img = Image.getInstance(tp); table.addCell(img); table.addCell(cell); p.add(table); document.add(p); } VUE.getActivePathway().setIndex(currentIndex); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:tufts.vue.PresentationNotes.java
License:Educational Community License
public static void createNodeNotes4PerPage(File file) { //page size notes: //martin-top,left,right,bottom = 36 //widht :612//from ww w .j a va 2 s . c om //height : 792 //usable space 540 x 720 // step 1: creation of a document-object Document document = new Document(PageSize.LETTER); try { GUI.activateWaitCursor(); // step 2: // we create a writer that listens to the document // and directs a PDF-stream to a file PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); // writer.setDefaultColorspace(PdfName.DEFAULTRGB, null); // writer.setStrictImageSequence(true); // step 3: we open the document document.open(); PdfPTable table; PdfPCell cell; int entryCount = 0; int entryOnPage = 0; Iterator i = VUE.getActiveMap().getAllDescendents(LWComponent.ChildKind.PROPER).iterator(); while (i.hasNext()) { LWComponent component = (LWComponent) i.next(); if (component instanceof LWNode) { final LWNode node = (LWNode) component; final String notes = node.getNotes(); entryCount++; table = new PdfPTable(new float[] { 1, 1 }); table.getDefaultCell().setBorder(0); table.setSpacingAfter(20.0f); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); Phrase phrase = new Phrase(notes); Font f = phrase.getFont(); f.setSize(8.0f); p.setFont(f); cell = new PdfPCell(phrase); cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cell.setBorder(0); PdfPCell i2 = new PdfPCell(); i2.setFixedHeight(172); i2.setBorder(0); //Render the table then throw the images on PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(SlideSizeX, SlideSizeY); Point2D.Float offset = new Point2D.Float(); //center vertically only if landscape mode //if (format.getOrientation() == PageFormat.LANDSCAPE) //TODO: allow horizontal centering, but not vertical centering (handle in computeZoomFit) Rectangle2D bounds = null; bounds = node.getBounds(); Dimension page = null; page = new Dimension(SlideSizeX, 172); // PdfTemplate tp = cb.createTemplate(document.getPageSize().width()-80, document.getPageSize().height()-80); double scale = ZoomTool.computeZoomFit(page, 15, bounds, offset, true); PdfGraphics2D g2d = (PdfGraphics2D) tp.createGraphics(SlideSizeX, SlideSizeY, getFontMapper(), false, 60.0f); DrawContext dc = new DrawContext(g2d, scale, -offset.x, -offset.y, null, // frame would be the PageFormat offset & size rectangle node, false); // todo: absolute links shouldn't be spec'd here dc.setClipOptimized(false); dc.setPrintQuality(); node.drawFit(dc, 15); g2d.dispose(); Image img = Image.getInstance(tp); table.addCell(img); table.addCell(cell); p.add(table); document.add(p); } } } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } finally { GUI.clearWaitCursor(); } // step 5: we close the document document.close(); }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
public void writeHead(Collection<CourseGroup> courseGroups, CourseComponent courseComponent) throws IOException { try {/* w w w .ja v a2 s .c o m*/ Paragraph paragraph; Phrase phrase; // Title paragraph = new Paragraph(); for (CourseGroup courseGroup : courseGroups) { phrase = new Phrase("\n" + courseGroup.getTitle(), titleFont); paragraph.add(phrase); } paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); // Component paragraph = new Paragraph(); phrase = new Phrase("\nComponent: " + courseComponent.getTitle(), authorFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); // Presenter paragraph = new Paragraph(); Person presenter = courseComponent.getPresenter(); phrase = new Phrase("\nPresenter: " + ((presenter == null) ? "" : presenter.getName()), authorFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); // Date paragraph = new Paragraph(); phrase = new Phrase("Date/Time: ...........................................", infoFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); document.add(paragraph); // info paragraph = new Paragraph(); phrase = new Phrase("Please sign to confirm that you have attended this session", infoFont); paragraph.add(phrase); paragraph.setIndentationLeft(25); paragraph.setIndentationRight(25); paragraph.setAlignment(Element.ALIGN_LEFT); document.add(paragraph); } catch (DocumentException e) { throw new IOException("Unable to write Document Header."); } }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
public void writeTableFoot() throws IOException { try {//from w w w.jav a 2 s . c o m for (int i = 0; i < 5; i++) { table.addCell(nameCell("", "", "")); table.addCell(""); } Paragraph paragraph = new Paragraph(); paragraph.add(table); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); } catch (DocumentException e) { throw new IOException("Unable to write Document table."); } }
From source file:util.ImprimirCIPDF.java
public Paragraph htmlToParagraph(String texto) throws IOException { StringReader strReader = new StringReader(texto); ArrayList p = new ArrayList(); p = HTMLWorker.parseToList(strReader, null); Paragraph paragrafo = new Paragraph(); for (int i = 0; i < p.size(); i++) { paragrafo.add((Element) p.get(i)); }//from w ww. j av a 2 s .c om paragrafo.setFont(fonte); return paragrafo; }
From source file:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildReportTitles</code></h2> * /*from ww w. j a va 2 s . c om*/ * <p> * Create the report headings * </p> * * @param DataSet reportTable - the report data object * */ private void buildReportTitles(DataSet reportTable) throws DocumentException, BadElementException, MalformedURLException, IOException { Paragraph title = new Paragraph(); title.add(Image.getInstance(dataAccess.getImagePath() + "reportLogo.gif")); title.add(new Chunk( new SimpleDateFormat(" " + "hh:mm:ss - dd MMM yyyy").format(new Date()), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); title.add(new Chunk(" " + reportTable.getStringField(ReportColumn.REPORT_TITLE), FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD))); HeaderFooter header = new HeaderFooter(title, false); header.setBorder(0); HeaderFooter footer = new HeaderFooter( new Phrase("page:", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL)), true); footer.setAlignment(HeaderFooter.ALIGN_CENTER); document.setHeader(header); document.setFooter(footer); reportColumns = reportTable.getTableVector(ReportColumn.REPORT_DETAILS).toArray(); topA = new ReportAccumulator(this, -1, reportColumns.length); bottomA = topA; reportBody = new PdfPTable(reportColumns.length); reportBody.setTotalWidth(1.100f); reportBody.setHeaderRows(1); float cW[] = new float[reportColumns.length]; for (int c = 0; c < reportColumns.length; c++) { ReportColumn column = (ReportColumn) reportColumns[c]; if (column.getLevelBreak() > 0) { ReportAccumulator r = new ReportAccumulator(this, c, reportColumns.length); bottomA.setChildAccumulator(r); r.setParentAccumulator(bottomA); column.setAccumulator(r); bottomA = r; } PdfPCell hdr = new PdfPCell(new Paragraph(column.getDescription(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD))); hdr.setBorder(Rectangle.BOTTOM); if (column.getAlignment().equals(ReportColumn.LEFT)) hdr.setHorizontalAlignment(Cell.ALIGN_LEFT); else if (column.getAlignment().equals(ReportColumn.RIGHT)) hdr.setHorizontalAlignment(Cell.ALIGN_RIGHT); else hdr.setHorizontalAlignment(Cell.ALIGN_CENTER); reportBody.addCell(hdr); cW[c] = (float) column.getLength(); } reportBody.setWidths(cW); }