Example usage for com.lowagie.text Image getInstance

List of usage examples for com.lowagie.text Image getInstance

Introduction

In this page you can find the example usage for com.lowagie.text Image getInstance.

Prototype

public static Image getInstance(Image image) 

Source Link

Document

gets an instance of an Image

Usage

From source file:tk.diginspect.main.SoOFSignatories.java

private void FDALetterhead() {
    try {//  w ww  .  j  a  v  a  2  s .co m
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        Bitmap bitmap = BitmapFactory.decodeResource(getBaseContext().getResources(),
                R.drawable.fda_letterhead);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        Image Img = Image.getInstance(stream.toByteArray());
        Img.setAlignment(Image.MIDDLE);
        Img.scalePercent(40f);
        doc.add(Img);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (BadElementException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:tufts.vue.PresentationNotes.java

License:Educational Community License

public static void createPresentationSlidesDeck(File file) {
    // step 1: creation of a document-object
    final Document document = new Document(PageSize.LETTER.rotate());

    try {//from  w  ww . j  a v  a  2  s  . c o m
        GUI.activateWaitCursor();
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file            
        final PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        writer.setDefaultColorspace(PdfName.DEFAULTRGB, null);
        writer.setStrictImageSequence(true);
        // step 3: we open the document

        document.open();

        final float pageWidth = document.getPageSize().getWidth();
        final float pageHeight = document.getPageSize().getHeight();
        final float fillWidth = pageWidth - 70;
        final float fillHeight = pageHeight - 70;

        if (DEBUG.Enabled) {
            System.out.println("\n---------------------------------");
            System.out.println("PDF DOCUMENT: pageSize " + document.getPageSize());
            System.out.println("fillWidth=" + fillWidth + " fillHeight=" + fillHeight);
        }
        int currentIndex = VUE.getActivePathway().getIndex();
        VUE.getActivePathway().setIndex(-1);
        for (LWPathway.Entry entry : VUE.getActivePathway().getEntries()) {

            if (DEBUG.Enabled)
                Log.debug("\n\nHANDLING DECK ENTRY " + entry);
            final LWSlide slide = entry.produceSlide();
            final LWComponent toDraw = (slide == null ? entry.node : slide);

            final PdfTemplate template = PdfTemplate.createTemplate(writer, fillWidth, fillHeight);
            final PdfGraphics2D graphics = (PdfGraphics2D) template.createGraphics(fillWidth, fillHeight,
                    getFontMapper(), false, 60.0f);
            final DrawContext dc = new DrawContext(graphics, 1.0);
            //                 //final DrawContext dc = new DrawContext(graphics, scale);
            //final DrawContext dc = new DrawContext(graphics, toDraw); // ideally, should use this
            dc.setClipOptimized(false);
            dc.setInteractive(false); // should be un-needed
            dc.setPrintQuality();

            // We set dc.focused to the node, which is needed for portals so they know to render contents in their clip-region.
            // Normally a portal knows to do this because it's the focal (dc.focal), but in this case, the dc.focal could,
            // at best, be the slide.  The current code actually uses NO focal in creating the DrawContext above,
            // and I'm not changing that just now as that would require lots of regression testing of printing.  SMF 6/24/10
            dc.focused = entry.node;

            if (DEBUG.Enabled) {
                Log.debug("DRAWING INTO " + dc + " g=" + graphics + " clip="
                        + tufts.Util.fmt(graphics.getClip()));
                if (DEBUG.PDF) {
                    dc.g.setColor(Color.green);
                    dc.g.fillRect(-Short.MAX_VALUE / 2, -Short.MAX_VALUE / 2, Short.MAX_VALUE, Short.MAX_VALUE);
                }
            }

            try {
                if (DEBUG.Enabled)
                    dc.clearDebug();
                toDraw.drawFit(dc, 0);
            } catch (Throwable t) {
                Log.error("exception drawing " + toDraw, t);
            }

            try {

                if (DEBUG.Enabled)
                    Log.debug("painted " + DrawContext.getDebug() + " to " + dc);

                if (DEBUG.PDF) {
                    final String dcDesc = dc.toString()
                            + String.format(" scale=%.1f%%", dc.g.getTransform().getScaleX() * 100);
                    dc.setRawDrawing();
                    dc.g.setColor(Color.red);
                    dc.g.setFont(VueConstants.FixedSmallFont);
                    dc.g.drawString(dcDesc, 10, fillHeight - 27);
                    dc.g.drawString(entry.toString(), 10, fillHeight - 16);
                    dc.g.drawString(toDraw.toString(), 10, fillHeight - 5);
                }

                // the graphics dispose appears to be very important -- we've seen completely intermittant
                // problems with generating many page PDF documents, which would be well explained by
                // java or internal itext buffers running out of memory.
                graphics.dispose();

                document.add(Image.getInstance(template));
                document.newPage();
            } catch (Throwable t) {
                Log.error("exception finishing " + toDraw + " in " + dc, t);
            }
        }
        VUE.getActivePathway().setIndex(currentIndex);
        if (DEBUG.Enabled)
            Log.debug("PROCESSED ALL ENTRIES");

    } 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 createSpeakerNotes4PerPage(File file) {
    //page size notes:
    //martin-top,left,right,bottom = 36
    //widht :612/*from w  w w .  j  a  va2s.  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  w ww .  ja  v a 2s. 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:vistas.reportes.procesos.rptAsistenciaTotal.java

public void crearPdf(String nombreFile, List<String> dnis, Date fechaInicio, Date fechaFin, String oficina,
        String tipo, String usuario, boolean isSelectedComp, boolean isSelectedHoraM)
        throws IOException, DocumentException {
    Document documento = new Document(PageSize.A4);
    PdfWriter.getInstance(documento, new FileOutputStream(nombreFile));
    documento.open();//from   w ww  . ja  v a 2 s . c om
    Image cabecera = Image.getInstance("img/cabecera.png");
    cabecera.setAlignment(1);
    documento.add(cabecera);
    String nombreGrupoOficina = "";
    if (tipo == "O") {
        nombreGrupoOficina = "DEPENDENCIA:      ";
    } else if (tipo == "G") {
        nombreGrupoOficina = "GRUPO HORARIO: ";
    } else if (tipo == "P") {
        nombreGrupoOficina = "DEPENDENCIA:      ";
    }
    Font font = new Font(Font.HELVETICA, 10, Font.BOLD);
    Chunk nombreReporte = new Chunk("REPORTE DE CONTROL DE ASISTENCIA",
            new Font(Font.HELVETICA, 12, Font.BOLD));
    Chunk labelOficina = new Chunk(nombreGrupoOficina, font);
    Chunk labelFechaInicio = new Chunk("FECHA INICIO:        ", font);
    Chunk labelFechaFin = new Chunk("       FECHA FIN: ", font);
    //Chunk labelUsuario = new Chunk("USUARIO: ",font);

    Chunk nombreOficina = new Chunk(oficina, new Font(Font.HELVETICA, 10));
    Chunk nombreFechaInicio = new Chunk(ReporteUtil.obtenerFechaFormateada(fechaInicio, "/").toUpperCase(),
            new Font(Font.HELVETICA, 10));
    Chunk nombreFechaFin = new Chunk(ReporteUtil.obtenerFechaFormateada(fechaFin, "/").toUpperCase(),
            new Font(Font.HELVETICA, 10));
    //Chunk nombreUsuario = new Chunk(usuario.toUpperCase(), new Font(Font.HELVETICA,10));

    Paragraph pNombreReporte = new Paragraph(nombreReporte);
    pNombreReporte.setAlignment(1);
    documento.add(pNombreReporte);
    documento.add(ReporteUtil.darEspaciado(25));
    documento.add(new Paragraph(ReporteUtil.unirChunks(labelOficina, nombreOficina)));
    documento.add(ReporteUtil.darEspaciado(15));
    if (tipo == "P") {
        Chunk labelDniEmpleado = new Chunk("DNI:                           ", font);
        Chunk labelNombreEmpleado = new Chunk("NOMBRE:                ", font);
        Empleado empleado = ec.buscarPorDni(dnis.get(0));
        Chunk nombreDni = new Chunk(empleado.getNroDocumento(), new Font(Font.HELVETICA, 10));
        Chunk nombreEmpleado = new Chunk(empleado.getApellidoPaterno() + " " + empleado.getApellidoMaterno()
                + " " + empleado.getNombre(), new Font(Font.HELVETICA, 10));
        documento.add(new Paragraph(ReporteUtil.unirChunks(labelNombreEmpleado, nombreEmpleado)));
        documento.add(ReporteUtil.darEspaciado(15));
        documento.add(new Paragraph(ReporteUtil.unirChunks(labelDniEmpleado, nombreDni)));
        documento.add(ReporteUtil.darEspaciado(15));
    }
    documento.add(new Paragraph(
            ReporteUtil.unirChunks(labelFechaInicio, nombreFechaInicio, labelFechaFin, nombreFechaFin)));
    documento.add(ReporteUtil.darEspaciado(15));

    //documento.add(new Paragraph(ReporteUtil.unirChunks(labelFechaFin,nombreFechaFin)));
    //documento.add(ReporteUtil.darEspaciado(15));
    //documento.add(new Paragraph(ReporteUtil.unirChunks(labelUsuario,nombreUsuario)));
    documento.add(ReporteUtil.darEspaciado(20));
    PdfPTable tabla = new rptAsistenciaTotal().crearTabla(dnis, fechaInicio, fechaFin, isSelectedComp,
            isSelectedHoraM, tipo);
    documento.add(tabla);
    documento.close();
    try {
        File path = new File(nombreFile);
        Desktop.getDesktop().open(path);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:vistas.reportes.procesos.rptTardanzaTotal.java

public void crearPdf(String nombreFile, List<String> dnis, Date fechaInicio, Date fechaFin, String oficina,
        String tipo, String usuario) throws IOException, DocumentException {
    Document documento = new Document(PageSize.A4.rotate());
    PdfWriter.getInstance(documento, new FileOutputStream(nombreFile));
    documento.open();//from  w w  w.  j av a  2s .c  om
    Image cabecera = Image.getInstance("img/cabecera.png");
    cabecera.setAlignment(1);
    documento.add(cabecera);
    String nombreGrupoOficina = "";
    if (tipo == "O") {
        nombreGrupoOficina = "OFICINA: ";
    } else {
        nombreGrupoOficina = "GRUPO HORARIO: ";
    }
    Font font = new Font(Font.TIMES_ROMAN, 10, Font.BOLD);
    Chunk nombreReporte = new Chunk("REPORTE DE CONSOLIDADO DE TARDANZA", font);
    Chunk labelOficina = new Chunk(nombreGrupoOficina, font);
    Chunk labelMes = new Chunk("MES: ", font);
    Chunk labelUsuario = new Chunk("USUARIO: ", font);

    Chunk nombreOficina = new Chunk(oficina, new Font(Font.TIMES_ROMAN, 10));
    Chunk nombreMes = new Chunk(ReporteUtil.obtenerNombreMes(fechaInicio).toUpperCase(),
            new Font(Font.TIMES_ROMAN, 10));
    Chunk nombreUsuario = new Chunk(usuario.toUpperCase(), new Font(Font.TIMES_ROMAN, 10));

    documento.add(new Paragraph(nombreReporte));
    documento.add(ReporteUtil.darEspaciado(15));
    documento.add(new Paragraph(ReporteUtil.unirChunks(labelOficina, nombreOficina)));
    documento.add(ReporteUtil.darEspaciado(15));
    documento.add(new Paragraph(ReporteUtil.unirChunks(labelMes, nombreMes)));
    documento.add(ReporteUtil.darEspaciado(15));
    documento.add(new Paragraph(ReporteUtil.unirChunks(labelUsuario, nombreUsuario)));
    documento.add(ReporteUtil.darEspaciado(20));
    PdfPTable tabla = new rptTardanzaTotal().crearTabla(dnis, fechaInicio, fechaFin);
    documento.add(tabla);
    documento.close();
    try {
        File path = new File(nombreFile);
        Desktop.getDesktop().open(path);
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

From source file:webBoltOns.server.reportWriter.JRivetWriter.java

License:Open Source License

/**
 * <h2><code>buildReportTitles</code></h2>
 * //from   w  w  w  . j a v  a  2 s. co  m
 * <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);
}

From source file:za.co.equalpay.web.utils.PDFExportUtility.java

/**
 * Perform the standard PDF PreProcessing: <br>
 * Add Customer logo image and Phrase as header to the first page, <br>
 * Add Line Separator to the bottom of the Image <br>
 * and add the standard footer message to the PDF document<br>
 *
 * @throws MalformedURLException/*  w  w w .ja  v  a2s.  co  m*/
 * @throws IOException
 * @throws DocumentException
 */
public void preProcess() throws MalformedURLException, IOException, DocumentException {
    document.setMargins(50f, 50f, 10f, 20f);

    BaseFont bf_helv = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false);
    // Font font = new Font(bf_helv, 8);

    ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext()
            .getContext();

    String fontPath = LogoPathFinder.getFontPath(servletContext, "Tahoma");
    BaseFont bf = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H, true);
    Font tahoma = new Font(bf, 16, Font.BOLD);
    tahoma.setColor(Color.GRAY);

    Font fontBold = new Font(bf, 8, Font.BOLD);
    fontBold.setColor(Color.GRAY);

    Font f = new Font(bf, 8, Font.NORMAL);
    f.setColor(Color.GRAY);

    Font sf = new Font(bf, 6, Font.NORMAL);
    sf.setColor(Color.LIGHT_GRAY);

    // image.setIndentationLeft(360f);
    // PdfPCell imgCell = new PdfPCell(image, false);
    // imgCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    // imgCell.setBorder(0);
    //
    // PdfPCell emptyCell = new PdfPCell(new Phrase("TESTING...", tahoma));
    // emptyCell.setBorder(0);
    // PdfPTable footerTable = new PdfPTable(1);
    // footerTable.setWidthPercentage(100);
    //
    //
    // phrase = new Phrase(PDF_FOOTER_MESSAGE, f);
    //
    // PdfPCell cell = new PdfPCell(phrase);
    // cell.setBorder(0);
    // footerTable.addCell(cell);
    // table.setWidths(new int[] { 1, 2 });
    // table.addCell(emptyCell);
    // footerTable.addCell(emptyCell);
    // phrase.add(footerTable);
    // phrase.add(new Chunk(image, 475f, 0));
    // Phrase subPhrase = new Phrase();
    // subPhrase.add(new Phrase("\nwww.meddev.co.za\n", sf));
    // subPhrase.add(new Phrase(PDF_FOOTER_MESSAGE, f));
    // phrase.add(subPhrase);
    // phrase.add(new Chunk("www.meddev.co.za", f));
    // phrase.add(new Phrase(PDF_FOOTER_MESSAGE, f));
    // load document footer
    HeaderFooter footer = new HeaderFooter(new Phrase(PDF_FOOTER_MESSAGE, f), false);
    // HeaderFooter footer = new HeaderFooter(paragraph, false);
    // HeaderFooter footer = new HeaderFooter(phrase, false);

    footer.setAlignment(Element.ALIGN_LEFT);
    footer.setBorder(Rectangle.NO_BORDER);
    document.setFooter(footer);

    // document.open();
    //
    // ByteArrayOutputStream baos = new ByteArrayOutputStream();
    // PdfWriter writer = PdfWriter.getInstance(document, baos);
    //
    // writer.open();
    // PdfContentByte cb = writer.getDirectContent();
    // cb.addImage(image);
    // ColumnText columnText = new ColumnText(cb);
    // load the customer logo
    String logoPath = LogoPathFinder.getPath(servletContext, "meddev-logo2");

    Image image = Image.getInstance(logoPath);
    image.scaleToFit(149, 55);
    image.setIndentationLeft(360f);

    PdfPCell imageCell = new PdfPCell(image, false);
    imageCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
    imageCell.setBorder(0);

    PdfPCell headerTextCell = new PdfPCell(new Phrase(header, tahoma));
    headerTextCell.setBorder(0);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100);
    table.setWidths(new int[] { 1, 2 });
    table.addCell(headerTextCell);
    table.addCell(imageCell);

    phrase = new Phrase();
    phrase.add(table);

    // load document header
    HeaderFooter header = new HeaderFooter(phrase, false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorder(Rectangle.NO_BORDER);

    document.setHeader(header);

    // create gray line separator
    // Chunk lineSeparator = new Chunk(new LineSeparator(1, 100, Color.GRAY,
    // Element.ALIGN_CENTER, -2));
    // document.add(lineSeparator);
    Font headerFont = new Font(bf_helv, 9);
    // write the header lines for this statement
    phrase = new Phrase(12, "\n", headerFont);
    phrase.add("\n\n");

    // open the pdf document for editing
    document.open();
    document.setPageSize(PageSize.A4);

    // Meddev Information Block
    table = new PdfPTable(4);
    table.setWidthPercentage(100);

    // table.setWidths(new int[] { 25, 25, 30, 20 });
    Phrase phrase1 = new Phrase();
    phrase1.add(new Phrase("MED DEV cc", fontBold));
    phrase1.add(new Phrase("\nUNIT 10, THE CORNER", f));
    phrase1.add(new Phrase("\nc/o Theuns & Hilde Ave", f));
    phrase1.add(new Phrase("\nHennopspark, 0157", f));
    phrase1.add(new Phrase("\nTel: +27 (0) 12 653 3063", f));
    phrase1.add(new Phrase("\nReg No: 2006/166603/23", f));
    phrase1.add(new Phrase("\n", f));

    Phrase phrase2 = new Phrase();
    phrase2.add(new Phrase("VAT No: ", fontBold));
    phrase2.add(new Phrase("4150231498", f));
    phrase2.add(new Phrase("\nImport/Export #: ", fontBold));
    phrase2.add(new Phrase("20544748", f));
    phrase2.add(new Phrase("\n", f));

    Phrase phrase3 = new Phrase();
    phrase3.add(new Phrase("QUOTE NO ", fontBold));
    phrase3.add(new Phrase("\nDATE ", fontBold));
    phrase3.add(new Phrase("\nREFERNCE ", fontBold));
    phrase3.add(new Phrase("\nSUPPLIER CODE ", fontBold));
    phrase3.add(new Phrase("\nEXPIRY DATE ", fontBold));

    Phrase phrase4 = new Phrase();
    //        phrase4.add(new Phrase(quotation.getQuotationNumber(), f));
    //        phrase4.add(new Phrase("\n" + DateFormatter.formatMonthDate(quotation.getQuotationDate()), f));
    //        phrase4.add(new Phrase("\n" + (quotation.getClient().getReference() == null ? "-" : quotation.getClient().getReference()), f));
    //        phrase4.add(new Phrase("\nMEDDEV1", f));
    //        phrase4.add(new Phrase("\n" + DateFormatter.formatMonthDate(quotation.calculateExpiryDate()), f));

    PdfPCell cell1 = new PdfPCell(phrase1);
    cell1.setBorder(0);
    PdfPCell cell2 = new PdfPCell(phrase2);
    cell2.setBorder(0);
    PdfPCell cell3 = new PdfPCell(phrase3);
    cell3.setBorder(0);
    PdfPCell cell4 = new PdfPCell(phrase4);
    cell4.setBorder(0);

    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    table.addCell(cell4);

    phrase.add(table);

    // create gray line separator
    Chunk lineSeparator = new Chunk(new LineSeparator(1, 100, Color.GRAY, Element.ALIGN_CENTER, -2));
    phrase.add(lineSeparator);

    // Customer Information Block
    table = new PdfPTable(3);
    table.setWidthPercentage(100);
    table.setWidths(new int[] { 5, 2, 3 });

    //        Phrase phrase11 = new Phrase();
    //        phrase11.add(new Phrase(quotation.getClient().getCompany().toUpperCase() + "(CLIENT)", fontBold));
    //        if (quotation.getClient().getVatRegNo() != null && quotation.getClient().getVatRegNo().trim().length() > 0) {
    //            phrase11.add(new Phrase("\nCustomer VAT No: ", fontBold));
    //            phrase11.add(new Phrase(quotation.getClient().getVatRegNo(), f));
    //        }
    //        if (quotation.getClient().getResAddress1() != null && quotation.getClient().getResAddress1().trim().length() > 0) {
    //            phrase11.add(new Phrase("\n" + quotation.getClient().getResAddress1(), f));
    //        }
    //        if (quotation.getClient().getResAddress2() != null && quotation.getClient().getResAddress2().trim().length() > 0) {
    //            phrase11.add(new Phrase("\n" + quotation.getClient().getResAddress2(), f));
    //        }
    //        if (quotation.getClient().getResCity() != null && quotation.getClient().getResCity().trim().length() > 0) {
    //            phrase11.add(new Phrase("\n" + quotation.getClient().getResCity(), f));
    //        }
    //        if (quotation.getClient().getPhone() != null && quotation.getClient().getPhone().trim().length() > 0) {
    //            phrase11.add(new Phrase("\nTel: " + quotation.getClient().getPhone(), f));
    //        }

    //PdfPCell cell11 = new PdfPCell(phrase11);
    //cell11.setBorder(0);

    phrase2 = new Phrase();
    phrase2.add(new Phrase("CURRENCY: ", fontBold));
    PdfPCell cell12 = new PdfPCell(phrase2);
    cell12.setBorder(0);

    phrase3 = new Phrase();
    //phrase3.add(new Phrase(quotation.getClient().getCurrencyCode(), f));
    PdfPCell cell13 = new PdfPCell(phrase3);
    cell13.setBorder(0);

    // table.addCell(cell11);
    table.addCell(cell12);
    table.addCell(cell13);

    phrase.add(table);

    // create gray line separator
    phrase.add("\n");
    document.add(phrase);

    String footerImagePath = LogoPathFinder.getPath(servletContext, "footer-image");

    Image footerImage = Image.getInstance(footerImagePath);
    footerImage.scaleToFit(90, 50);
    footerImage.setAbsolutePosition((PageSize.A4.getWidth() - (footerImage.getScaledWidth() + 40)),
            (PageSize.A4.getHeight() - (PageSize.A4.getHeight() - (footerImage.getScaledHeight() - 10))));

    document.add(footerImage);

}