List of usage examples for com.lowagie.text.pdf PdfPCell setBorder
public void setBorder(int border)
From source file:storemanagment.Printing.java
public PdfPCell createTextCellNb(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); p.add(text);//from w w w . j a v a 2s.co m cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }
From source file:storemanagment.Printing.java
public PdfPCell createTextCell(String text) { PdfPCell cell = new PdfPCell(); Paragraph p = new Paragraph(); p.setFont(FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, java.awt.Font.BOLD)); // p.setFont(Font.BOLD); p.setAlignment(Element.ALIGN_CENTER); p.add(text);//from w w w. j a va 2 s . c o m cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }
From source file:storemanagment.Printing.java
public PdfPCell createTextCellNormal(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);// w w w . ja va 2 s.c o m cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }
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);/*from w w w . j a v a 2s.c o m*/ cell.addElement(p); cell.setBorder(Rectangle.NO_BORDER); cell.setVerticalAlignment(Rectangle.NO_BORDER); return cell; }
From source file:storemanagment.Printing.java
public PdfPCell createImageCell(String path) throws IOException { PdfPCell cell = null; try {//from www . jav a2 s. c om Image img = Image.getInstance(path); cell = new PdfPCell(img, true); cell.setFixedHeight(30); cell.setBorder(Rectangle.NO_BORDER); cell.setPaddingTop(10); } catch (BadElementException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } return cell; }
From source file:subcentro_licto.presentacion.beans.DatosBuscadorBean.java
public void imprimirDatos() { //DateFormat dfDateFull = DateFormat.getDateInstance(DateFormat.FULL); try {/*www .ja va 2s . c o m*/ //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:tk.diginspect.main.SoOFSignatories.java
private void Checked(PdfPTable table, int align, int checkmark) { try {// w w w . ja va2 s. c o m ByteArrayOutputStream streamChecked = new ByteArrayOutputStream(); Bitmap Checked = BitmapFactory.decodeResource(getBaseContext().getResources(), checkmark); Checked.compress(Bitmap.CompressFormat.JPEG, 100, streamChecked); Image ImgChecked = null; ImgChecked = Image.getInstance(streamChecked.toByteArray()); ImgChecked.scalePercent(25f); PdfPCell cell = new PdfPCell(ImgChecked, false); cell.setHorizontalAlignment(align); cell.setPadding(5); cell.setBorder(0); table.addCell(cell); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
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/* www .j a v a2 s .c o 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 v a 2 s . c o 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; 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:webBoltOns.server.reportWriter.JRivetWriter.java
License:Open Source License
/** * <h2><code>buildBlankLine</code></h2> * // w w w . ja va 2 s . co m * <p> * build a 'blank' line * </p> */ private void buildBlankLine() throws DocumentException { if (++rowCount < pageLength) { PdfPCell cell; for (int c = 0; c < reportColumns.length; c++) { cell = new PdfPCell( new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL))); cell.setBorder(0); cell.setBackgroundColor(totalColor); reportBody.addCell(cell); } } }