Example usage for com.itextpdf.text Element ALIGN_LEFT

List of usage examples for com.itextpdf.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.itextpdf.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:nwk.com.br.documents.ProdutoMaisVendidoPdf.java

private PdfPTable getProduto() throws Exception {
    PdfPTable produtoMaisVendido = new PdfPTable(new float[] { 0.1f/*id*/, 0.65f/*nome*/, 0.25f/*soma*/ });
    produtoMaisVendido.setWidthPercentage(100.0f);//seta o tamanho da tabela em relaao ao documento
    produtoMaisVendido.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    produtoMaisVendido.getDefaultCell().setBorder(0);

    //Adiciona os nomes das colunas
    PdfPCell codProduto = new PdfPCell(new Paragraph("Cod"));
    PdfPCell descProduto = new PdfPCell(new Paragraph("Descrio"));
    PdfPCell qtdProduto = new PdfPCell(new Paragraph("Quantidade"));

    produtoMaisVendido.addCell(codProduto);
    produtoMaisVendido.addCell(descProduto);
    produtoMaisVendido.addCell(qtdProduto);

    //Adiciona as informaes do cliente na tabela
    int qtdCli = 0;
    for (Produto produto : produtodao.getProdutoeMaisVendido()) {
        produtoMaisVendido.addCell(produto.getId());
        produtoMaisVendido.addCell(produto.getDescricao());
        produtoMaisVendido.addCell(produto.getQuantidade());

        if (qtdCli == 19) {
            break;
        } else {//from   w  w  w  . java 2  s  .  c o m
            qtdCli++;
        }
    }

    return produtoMaisVendido;
}

From source file:nz.ac.waikato.cms.doc.HyperLinkGrades.java

License:Open Source License

/**
 * Adds the index with locations to the existing PDF.
 *
 * @param locations   the locations to index
 * @param input   the input PDF//from   w  ww. ja v  a2  s. c  o m
 * @param output   the output PDF
 * @return      true if successfully generated
 */
public static boolean addIndex(List<Location> locations, File input, File output) {
    try {
        // copy pages, add target
        PdfReader reader = new PdfReader(input.getAbsolutePath());
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(output.getAbsolutePath()));
        document.open();
        PdfContentByte canvas = writer.getDirectContent();
        PdfImportedPage page;
        float height = 0;
        for (int i = 1; i <= reader.getNumberOfPages(); i++) {
            document.newPage();
            page = writer.getImportedPage(reader, i);
            canvas.addTemplate(page, 1f, 0, 0, 1, 0, 0);
            Chunk loc = new Chunk(" ");
            loc.setLocalDestination("loc" + i);
            height = page.getHeight();
            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(loc), 50, height - 50, 0);
        }
        // add index
        for (int i = 0; i < locations.size(); i++) {
            Location loc = locations.get(i);
            if (i % MAX_ITEMS_PER_PAGE == 0)
                document.newPage();
            String text = loc.getID() + " " + (loc.getName() == null ? "???" : loc.getName());
            Chunk chunk = new Chunk("Page " + (loc.getPage() + 1) + ": " + text);
            chunk.setAction(PdfAction.gotoLocalPage("loc" + (loc.getPage() + 1), false));
            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase(chunk), 50,
                    height - 100 - (i % MAX_ITEMS_PER_PAGE) * 20, 0);
        }
        document.close();

        return true;
    } catch (Exception e) {
        System.err.println("Failed to overlay locations!");
        e.printStackTrace();
        return false;
    }
}

From source file:nz.ac.waikato.cms.doc.OverlayFilename.java

License:Open Source License

/**
 * Performs the overlay.// w  ww .j av  a  2  s  .  c  o  m
 *
 * @param input   the input file/dir
 * @param output   the output file/dir
 * @param vpos   the vertical position
 * @param hpos   the horizontal position
 * @param stripPath   whether to strip the path
 * @param stripExt   whether to strip the extension
 * @param pages   the array of pages (1-based) to add the overlay to, null for all
 * @param evenPages   whether to enforce even pages in the document
 * @return      true if successfully overlay
 */
public boolean overlay(File input, File output, int vpos, int hpos, boolean stripPath, boolean stripExt,
        int[] pages, boolean evenPages) {
    PdfReader reader;
    PdfStamper stamper;
    FileOutputStream fos;
    PdfContentByte canvas;
    int i;
    String text;
    int numPages;
    File tmpFile;
    Document document;
    PdfWriter writer;
    PdfImportedPage page;
    PdfContentByte cb;

    reader = null;
    stamper = null;
    fos = null;
    numPages = -1;
    try {
        reader = new PdfReader(input.getAbsolutePath());
        fos = new FileOutputStream(output.getAbsolutePath());
        stamper = new PdfStamper(reader, fos);
        numPages = reader.getNumberOfPages();
        if (pages == null) {
            pages = new int[reader.getNumberOfPages()];
            for (i = 0; i < pages.length; i++)
                pages[i] = i + 1;
        }

        if (stripPath)
            text = input.getName();
        else
            text = input.getAbsolutePath();
        if (stripExt)
            text = text.replaceFirst("\\.[pP][dD][fF]$", "");

        for (i = 0; i < pages.length; i++) {
            canvas = stamper.getOverContent(pages[i]);
            ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Paragraph(text), hpos, vpos, 0.0f);
        }
    } catch (Exception e) {
        System.err.println("Failed to process " + input + ":");
        e.printStackTrace();
        return false;
    } finally {
        try {
            if (stamper != null)
                stamper.close();
        } catch (Exception e) {
            // ignored
        }
        try {
            if (reader != null)
                reader.close();
        } catch (Exception e) {
            // ignored
        }
        try {
            if (fos != null) {
                fos.flush();
                fos.close();
            }
        } catch (Exception e) {
            // ignored
        }
    }

    // enforce even pages?
    if (evenPages && (numPages > 0) && (numPages % 2 == 1)) {
        reader = null;
        fos = null;
        writer = null;
        tmpFile = new File(output.getAbsolutePath() + "tmp");
        try {
            if (!output.renameTo(tmpFile)) {
                System.err.println("Failed to rename '" + output + "' to '" + tmpFile + "'!");
                return false;
            }
            reader = new PdfReader(tmpFile.getAbsolutePath());
            document = new Document(reader.getPageSize(1));
            fos = new FileOutputStream(output.getAbsoluteFile());
            writer = PdfWriter.getInstance(document, fos);
            document.open();
            document.addCreationDate();
            document.addAuthor(System.getProperty("user.name"));
            cb = writer.getDirectContent();
            for (i = 0; i < reader.getNumberOfPages(); i++) {
                page = writer.getImportedPage(reader, i + 1);
                document.newPage();
                cb.addTemplate(page, 0, 0);
            }
            document.newPage();
            document.add(new Paragraph(" ")); // fake content
            document.close();
        } catch (Exception e) {
            System.err.println("Failed to process " + tmpFile + ":");
            e.printStackTrace();
            return false;
        } finally {
            try {
                if (fos != null) {
                    fos.flush();
                    fos.close();
                }
            } catch (Exception e) {
                // ignored
            }
            try {
                if (reader != null)
                    reader.close();
            } catch (Exception e) {
                // ignored
            }
            try {
                if (writer != null)
                    writer.close();
            } catch (Exception e) {
                // ignored
            }
            if (tmpFile.exists()) {
                try {
                    tmpFile.delete();
                } catch (Exception e) {
                    // ignored
                }
            }
        }
    }

    return true;
}

From source file:nz.ac.waikato.cms.doc.SimplePDFOverlay.java

License:Open Source License

/**
 * Parses the alignment string.//from  w  w  w.  ja v  a2s .  c  o  m
 *
 * @param str      the alignment string
 * @return      the alignment, see {@link Element}
 */
protected int parseAlignment(String str) {
    switch (str) {
    case "UNDEFINED":
        return Element.ALIGN_UNDEFINED;
    case "LEFT":
        return Element.ALIGN_LEFT;
    case "CENTER":
        return Element.ALIGN_CENTER;
    case "RIGHT":
        return Element.ALIGN_RIGHT;
    case "JUSTIFIED":
        return Element.ALIGN_JUSTIFIED;
    default:
        m_Logger.warning("Unhandled alignment, falling back to LEFT: " + str);
        return Element.ALIGN_LEFT;
    }
}

From source file:om.edu.squ.squportal.portlet.tsurvey.dao.pdf.TeachingSurveyPdfImpl.java

License:Open Source License

/**
 *    //from  w  w w .j a v  a  2 s.  c  om
 * method name  : getPdfCell
 * @param content
 * @param rowSpan
 * @param colSpan
 * @return
 * TeachingSurveyPdfImpl
 * return type  : PdfPCell
 * 
 * purpose      : 
 *
 * Date          :   Feb 22, 2016 12:52:28 PM
 */
private PdfPCell getPdfCell(String content, int rowSpan, int colSpan, Font font, String txtAlign) {
    PdfPCell cell = new PdfPCell(new Phrase(content, font));

    if (rowSpan == 0 && colSpan != 0) {
        cell.setColspan(colSpan);
    }
    if (rowSpan != 0 && colSpan == 0) {
        cell.setRowspan(rowSpan);
    }

    if (txtAlign.equals(Constants.CENTER))
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    if (null == txtAlign || txtAlign.equals(Constants.LEFT))
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    if (txtAlign.equals(Constants.RIGHT))
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);

    return cell;
}

From source file:Operaciones.Destajo.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//from www.  j  a  v a  2 s . c  o m
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        session.beginTransaction().begin();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        //Orden ord=buscaApertura();
        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord);
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER.rotate(), "Valuacin", "reportes/" + ord + "/" + valor + "-destajo.pdf");
        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        float tam[] = new float[] { 150, 50, 100, 300 };
        PdfPTable tabla = reporte.crearTabla(4, tam, 100, Element.ALIGN_LEFT);

        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
        formatoPorcentaje.setMinimumFractionDigits(2);

        cabecera(reporte, bf, tabla);

        session.beginTransaction().begin();
        Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(this.ord));
        List cuentas = null;
        for (int x = 0; x < t_datos.getRowCount(); x++) {
            tabla.addCell(reporte.celda(t_datos.getValueAt(x, 1).toString(), font, contenido, izquierda, 0, 1,
                    Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(formatoPorcentaje.format((Double) t_datos.getValueAt(x, 2)), font,
                    contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(formatoPorcentaje.format((Double) t_datos.getValueAt(x, 3)), font,
                    contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(t_datos.getValueAt(x, 4).toString(), font, contenido, izquierda, 0, 1,
                    Rectangle.RECTANGLE));
        }
        session.beginTransaction().rollback();

        tabla.setHeaderRows(1);
        reporte.agregaObjeto(tabla);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord + "/" + valor + "-destajo.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
    if (session != null)
        if (session.isOpen()) {
            session.flush();
            session.clear();
            session.close();
        }
}

From source file:Operaciones.Destajo.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//from   www .  j  av a 2s  .  c om
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        session.beginTransaction().begin();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        //Orden ord=buscaApertura();
        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord);
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER.rotate(), "Valuacin", "reportes/" + ord + "/" + valor + "-destajo.pdf");
        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        float tam[] = new float[] { 150, 50, 100, 300 };
        PdfPTable tabla = reporte.crearTabla(4, tam, 100, Element.ALIGN_LEFT);

        cabecera(reporte, bf, tabla);

        session.beginTransaction().begin();
        Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(this.ord));
        List cuentas = null;
        for (int x = 0; x < 21; x++) {
            tabla.addCell(reporte.celda(" \n ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(" \n ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(" \n ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(" \n ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
        }
        session.beginTransaction().rollback();

        tabla.setHeaderRows(1);
        reporte.agregaObjeto(tabla);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord + "/" + valor + "-destajo.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
    if (session != null)
        if (session.isOpen()) {
            session.flush();
            session.clear();
            session.close();
        }
}

From source file:Operaciones.Destajo.java

public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from  w  w  w. j a  v a 2  s  .c  om
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(160, 515, 210, 45, 5);
        reporte.contenido.roundRectangle(380, 515, 375, 45, 5);
        reporte.contenido.roundRectangle(35, 480, 720, 30, 5);

        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 160, 580, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Hoja de Avance", 160, 570, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 760, 580, 0);

        Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(ord));
        Foto foto = (Foto) session.createCriteria(Foto.class)
                .add(Restrictions.eq("orden.idOrden", Integer.parseInt(ord))).addOrder(Order.desc("fecha"))
                .setMaxResults(1).uniqueResult();
        if (foto != null) {
            reporte.agregaObjeto(reporte.crearImagen(
                    "ordenes/" + dato.getIdOrden() + "/" + foto.getDescripcion(), 0, -60, 120, 80, 0));
        } else {
        }
        //************************datos de la orden****************************
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Orden:" + dato.getIdOrden(), 164, 550, 0);

        if (dato.getFecha() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:" + dato.getFecha(), 285,
                    550, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Apertura:", 285, 550, 0);

        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Compaia:" + dato.getCompania().getIdCompania() + " " + dato.getCompania().getNombre(), 164,
                540, 0);

        if (dato.getSiniestro() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:" + dato.getSiniestro(),
                    164, 530, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Siniestro:", 164, 530, 0);

        if (dato.getFechaSiniestro() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "F. Siniestro:" + dato.getFechaSiniestro(), 285, 530, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "F.Siniestro:", 285, 530, 0);

        if (dato.getPoliza() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:" + dato.getPoliza(), 164, 520,
                    0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Poliza:", 164, 520, 0);

        if (dato.getInciso() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:" + dato.getInciso(), 285, 520,
                    0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Inciso:", 285, 520, 0);
        //**********************************************************

        //************datos de la unidad
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Unidad:" + dato.getTipo().getTipoNombre(),
                385, 550, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Modelo:" + dato.getModelo(), 664, 550,
                0);

        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Marca:" + dato.getMarca().getMarcaNombre(), 385, 540, 0);
        if (dato.getNoEconomico() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:" + dato.getNoEconomico(),
                    664, 540, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Economico:", 664, 540, 0);

        if (dato.getNoMotor() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:" + dato.getNoMotor(), 385,
                    530, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Motor:", 385, 530, 0);

        if (dato.getNoSerie() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:" + dato.getNoSerie(), 385,
                    520, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N Serie:", 385, 520, 0);
        //*************************************************************

        switch (this.global) {
        case "h":
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Hojalateria", 40, 495,
                    0);
            break;
        case "m":
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Mecanica", 40, 495, 0);
            break;
        case "s":
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Suspension", 40, 495,
                    0);
            break;
        case "e":
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: electrico", 40, 495, 0);
            break;
        case "p":
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Especialidad: Pintura", 40, 495, 0);
            break;
        }
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Empleado:" + t_responsable.getText(), 165,
                495, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Fecha Asignacin:" + t_asignacion.getText(), 430, 495, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Fecha Limite:" + t_limite.getText(), 600,
                495, 0);

        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Monto x Hora: $" + t_monto.getText(), 40,
                485, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Horas Totales: " + t_horas.getText(), 165,
                485, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Importe a Pagar: $" + t_importe.getText(),
                600, 485, 0);

        reporte.finTexto();
        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);

        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;

        tabla.addCell(reporte.celda("Fecha Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("% de Avance", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Importe Pagado", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Notas", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen()) {
            session.flush();
            session.clear();
            session.close();
        }
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void addUserDetails(PdfPTable t, String key, String value) {
    PdfPCell c;//from www  .  j  a v  a2s.c o  m
    Paragraph p = new Paragraph();

    Chunk keyChunk = new Chunk(key, BLACK_NORMAL);
    Chunk valChunk = new Chunk(value, BLACK_BOLD);

    p.add(keyChunk);
    p.add(valChunk);

    c = new PdfPCell(p);
    c.setHorizontalAlignment(Element.ALIGN_LEFT);
    c.setBorder(0);
    t.addCell(c);
}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void addTableRow(PdfPTable table, Change change)
        throws BadElementException, MalformedURLException, IOException {
    PdfPCell cell = new PdfPCell(new Phrase(change.getElementType()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);//from   w  w  w.j  ava 2 s .  co m

    cell = new PdfPCell(new Phrase(change.getElementName()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(change.getPropertyName()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(change.getDescription()));
    cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setPadding(4f);
    table.addCell(cell);

    cell = new PdfPCell(getImageForStatus(change.getStatus()), false);
    cell.setPadding(10f);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    String reviewed = Messages.no;
    if (change.isReviewed()) {
        reviewed = Messages.yes;
    }
    cell = new PdfPCell(new Phrase(reviewed));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);
}