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:com.vectorprint.report.itext.EventHelper.java

License:Open Source License

/**
 * prints a failure and / or a debug header when applicable.
 *
 * @see #getTemplateImage(com.itextpdf.text.pdf.PdfTemplate)
 * @param writer//w w w.ja v a2  s .  c o m
 * @param document
 * @throws DocumentException
 * @throws VectorPrintException
 */
private final void renderHeader(PdfWriter writer, Document document)
        throws DocumentException, VectorPrintException {
    if ((!debugHereAfter && getSettings().getBooleanProperty(false, DEBUG))
            || (!failuresHereAfter && !getSettings().getBooleanProperty(false, DEBUG))) {

        writer.getDirectContent().addImage(getTemplateImage(template));

        if (getSettings().getBooleanProperty(false, DEBUG)) {
            ArrayList a = new ArrayList(2);
            a.add(PdfName.TOGGLE);
            a.add(elementProducer.initLayerGroup(DEBUG, writer.getDirectContent()));
            PdfAction act = PdfAction.setOCGstate(a, true);
            Chunk h = new Chunk("toggle debug info",
                    DebugHelper.debugFontLink(writer.getDirectContent(), getSettings())).setAction(act);

            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(h), 10,
                    document.top() - 15, 0);
            Font f = DebugHelper.debugFontLink(writer.getDirectContent(), getSettings());
            //            act = PdfAction.gotoLocalPage("debugpage", true);

            elementProducer.startLayerInGroup(DEBUG, writer.getDirectContent());

            h = new Chunk(getSettings().getProperty("go to debug legend", "debugheader"), f)
                    .setLocalGoto(BaseReportGenerator.DEBUGPAGE);
            ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT, new Phrase(h), 10,
                    document.top() - 3, 0);

            writer.getDirectContent().endLayer();

        }
    }
}

From source file:com.vectorprint.report.itext.style.stylers.Text.java

License:Open Source License

@Override
protected void draw(PdfContentByte canvas, float x, float y, float width, float height, String genericTag)
        throws VectorPrintException {
    BaseFont bf = FontFactory.getFont(getAlias()).getBaseFont();
    if (bf == null) {
        throw new VectorPrintRuntimeException(
                "font " + getAlias() + " does not have a basefont, check your fontloading");
    }//  ww w  .  j  av  a2s  .  co  m
    canvas.setFontAndSize(bf, getSize());
    canvas.setColorFill(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getColor()));
    canvas.setColorStroke(itextHelper.fromColor((isDrawShadow()) ? getShadowColor() : getColor()));
    canvas.beginText();
    canvas.showTextAligned(Element.ALIGN_LEFT, getData(), x, y, getRotate());
    canvas.endText();
    if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG)) {
        DebugHelper.styleLink(canvas, getStyleClass(), " (styling)", x, y, getSettings(), getLayerManager());
    }
}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsListReportType.java

License:Open Source License

protected void showSubRowDataOnPdfForWholeReport(int position) {
    AbsListReportSubDisplayBean subDisplayBean = this.alrbean.getSubdisplaybean();
    if (subDisplayBean == null)
        return;/*from   w  ww.  j a  v a2 s  . co  m*/
    List<AbsListReportSubDisplayRowBean> lstStatiDisplayRowBeans = subDisplayBean.getLstSubDisplayRowBeans();
    if (lstStatiDisplayRowBeans == null || lstStatiDisplayRowBeans.size() == 0)
        return;
    //        Object subdisplayDataObj=subDisplayBean.getPojoObject();
    List<AbsListReportSubDisplayColBean> lstStatiColBeans = null;
    for (AbsListReportSubDisplayRowBean sRowBeanTmp : lstStatiDisplayRowBeans) {
        /****if(sRowBeanTmp.getDisplaytype()==AbsListReportStatiBean.STATIROW_DISPLAYTYPE_PAGE)
        {
        if(rrequest.getShowtype()!=Consts.DISPLAY_ON_PAGE&&!this.cacheDataBean.isExportPrintPartData()) continue;
        if(rrequest.getShowtype()==Consts.DISPLAY_ON_PAGE&&cacheDataBean.getPagesize()<0) continue;
        }else if(sRowBeanTmp.getDisplaytype()==AbsListReportStatiBean.STATIROW_DISPLAYTYPE_REPORT)
        {
        if(rrequest.getShowtype()!=Consts.DISPLAY_ON_PAGE&&this.cacheDataBean.isExportPrintPartData()
                ||rrequest.getShowtype()==Consts.DISPLAY_ON_PAGE&&cacheDataBean.getPagesize()>0)
        {
            if(cacheDataBean.getFinalPageno()!=cacheDataBean.getPagecount()) continue;//??
        }
        }*/
        if (sRowBeanTmp.getDisplayposition() != AbsListReportSubDisplayBean.SUBROW_POSITION_BOTH
                && sRowBeanTmp.getDisplayposition() != position)
            continue;
        lstStatiColBeans = sRowBeanTmp.getLstSubColBeans();
        if (lstStatiColBeans == null || lstStatiColBeans.size() == 0)
            continue;
        String stativalue;
        int startcolidx = 0;
        int endcolidx = -1;
        for (AbsListReportSubDisplayColBean scbean : lstStatiColBeans) {
            stativalue = getSubColDisplayValue(this.subDisplayDataObj, scbean);
            stativalue = Tools.replaceAll(stativalue, "&nbsp;", " ");
            stativalue = stativalue.replaceAll("<.*?\\>", "");
            if (rbean.getDbean().isDataexportColselect() || lstStatiColBeans.size() == 1
                    || (cacheDataBean.getAttributes().get("authroize_col_display") != null
                            && String.valueOf(cacheDataBean.getAttributes().get("authroize_col_display")).trim()
                                    .equals("false"))
                    || alrbean.hasControllCol()) {
                startcolidx = 0;
                endcolidx = cacheDataBean.getTotalColCount();//???
                int deltaCount = 0;
                if (alrdbean.getRowGroupColsNum() > 0 && alrdbean.getRowgrouptype() == 2) {
                    deltaCount = alrdbean.getRowGroupColsNum() - 1;
                }
                endcolidx = endcolidx + deltaCount;
            } else {
                startcolidx = endcolidx + 1;
                endcolidx = startcolidx + scbean.getPlainexcel_colspan();
            }
            addDataCell(scbean, stativalue, 1, endcolidx - startcolidx, Element.ALIGN_LEFT);
        }
    }
}

From source file:com.wabacus.system.component.application.report.abstractreport.AbsReportType.java

License:Open Source License

protected int getPdfCellAlign(String configalign, int defaultalign) {
    if (configalign == null || configalign.trim().equals(""))
        return defaultalign;
    configalign = configalign == null ? "" : configalign.toLowerCase().trim();
    if (configalign.equals("left"))
        return Element.ALIGN_LEFT;
    if (configalign.equals("center"))
        return Element.ALIGN_CENTER;
    if (configalign.equals("right"))
        return Element.ALIGN_RIGHT;
    return defaultalign;
}

From source file:com.wabacus.system.component.application.report.CrossListReportType.java

License:Open Source License

protected void showSubRowDataOnPdfForWholeReport(int position) {
    if (position == AbsListReportSubDisplayBean.SUBROW_POSITION_BOTTOM
            && this.lstVerticalStatiColBeansAndValues != null
            && this.lstVerticalStatiColBeansAndValues.size() > 0) {
        String stativalue;/*from w ww . j a  v  a2s .  co m*/
        int startcolidx = 0;
        int endcolidx = -1;
        CellRangeAddress region;
        for (VerticalCrossStatisticColData vcDataTmp : this.lstVerticalStatiColBeansAndValues) {
            stativalue = vcDataTmp.getColValue();
            stativalue = Tools.replaceAll(stativalue, "&nbsp;", " ");
            stativalue = stativalue.replaceAll("<.*?\\>", "");//?html
            startcolidx = endcolidx + 1;
            endcolidx = startcolidx + vcDataTmp.getColspan();
            addDataCell(vcDataTmp.getCbean(), stativalue, 1, endcolidx - startcolidx, Element.ALIGN_LEFT);
        }
    }
    super.showSubRowDataOnPdfForWholeReport(position);
}

From source file:com.wabacus.system.component.application.report.DetailReportType.java

License:Open Source License

private void showReportDataOnPdf() {
    DisplayBean dbean = rbean.getDbean();
    if (lstReportData == null || lstReportData.size() == 0) {
        lstReportData = new ArrayList<AbsReportDataPojo>();
        lstReportData.add(//  w w w  . j ava  2 s.co  m
                ReportAssistant.getInstance().getPojoClassInstance(rrequest, rbean, rbean.getPojoClassObj()));//POJO?
    }
    for (AbsReportDataPojo rowDataObjTmp : this.lstReportData) {
        if (this.pdfpagesize > 0 && this.pdfrowindex != 0 && this.pdfrowindex % this.pdfpagesize == 0) {
            this.createNewPdfPage();
        }
        DetailReportColBean drcolbean = null;
        ColDisplayData colDisplayData;
        DetailReportColPositionBean colPositionBeanTmp;
        int colspan;
        String labelTmp;
        for (ColBean cbean : dbean.getLstCols()) {
            if (Consts.COL_DISPLAYTYPE_HIDDEN
                    .equals(cbean.getDisplaytype(rrequest.getShowtype() == Consts.DISPLAY_ON_PAGE)))
                continue;
            drcolbean = (DetailReportColBean) cbean.getExtendConfigDataForReportType(KEY);
            colPositionBeanTmp = mColPositions.get(cbean.getColid());
            if (colPositionBeanTmp.getDisplaymode() > 0) {
                labelTmp = cbean.getLabel(rrequest);
                if (labelTmp != null && !ColBean.NON_LABEL.equals(labelTmp)) {//<col/>label??
                    colDisplayData = ColDisplayData.getColDataFromInterceptor(this, cbean, null, -1, null,
                            labelTmp);
                    colspan = drcolbean.getLabelcolspan();
                    if (colspan <= 0)
                        colspan = 1;
                    addDataHeaderCell(cbean, colDisplayData.getValue(), 1, colspan,
                            this.getPdfCellAlign(cbean.getLabelalign(), Element.ALIGN_LEFT));
                }
                if (!cbean.isNonValueCol()) {
                    String valueTmp = rowDataObjTmp.getColStringValue(cbean);
                    colDisplayData = ColDisplayData.getColDataFromInterceptor(this, cbean, rowDataObjTmp,
                            this.pdfrowindex, null, valueTmp);
                    colspan = colPositionBeanTmp.getColspan();
                    if (colspan <= 0)
                        colspan = 1;
                    addDataCell(cbean, colDisplayData.getValue(), 1, colspan,
                            this.getPdfCellAlign(cbean.getValuealign(), Element.ALIGN_LEFT));
                }
            }
        }
        this.pdfrowindex++;
    }
}

From source file:comisionesafis.informes.FacturasComisionesAgentes.java

public boolean generar() {

    // Abrimos el fichero de comisiones
    Periodos periodos = new Periodos(pb.getFicheroComisiones());
    String sSQL = "";
    Statement stmt;/*from   ww  w. j a  v  a 2 s  .  c o m*/
    ResultSet rsComisiones;
    String sFactura1;
    String sFactura2;

    // Generamos la sentencia de Seleccin de Datos
    try {

        // Generamos el PDF
        Document documento = new Document(PageSize.A4, 80, 80, 50, 50);
        FileOutputStream salida = new FileOutputStream("FacturasComisionesAgentes.pdf");
        PdfWriter writer = PdfWriter.getInstance(documento, salida);
        writer.setInitialLeading(0);

        //  Obtenemos una instancia de nuestro manejador de eventos
        FacturasComisionesAgentesPie pie = new FacturasComisionesAgentesPie();
        //Asignamos el manejador de eventos al escritor.
        writer.setPageEvent(pie);

        // Abrimos el Documento
        documento.open();

        sSQL = "SELECT * ";
        sSQL += "  FROM ResumenComisiones";
        sSQL += " ORDER BY CodAgente";
        stmt = conexion.createStatement();
        rsComisiones = stmt.executeQuery(sSQL);

        while (rsComisiones.next()) {

            // Generamos los prrafos
            // Datos del agente
            Paragraph pAgente[] = new Paragraph[5];
            pAgente[0] = new Paragraph();
            pAgente[0].add(rsComisiones.getString("Nombre"));
            pAgente[0].setAlignment(Paragraph.ALIGN_LEFT);
            pAgente[1] = new Paragraph();
            pAgente[1].add(rsComisiones.getString("Direccion"));
            pAgente[1].setAlignment(Paragraph.ALIGN_LEFT);
            pAgente[2] = new Paragraph();
            pAgente[2].add(rsComisiones.getString("CodPostal") + "  " + rsComisiones.getString("Poblacion"));
            pAgente[2].setAlignment(Paragraph.ALIGN_LEFT);
            pAgente[3] = new Paragraph();
            pAgente[3].add(rsComisiones.getString("Provincia"));
            pAgente[3].setAlignment(Paragraph.ALIGN_LEFT);
            pAgente[4] = new Paragraph();
            pAgente[4].add(rsComisiones.getString("NIF"));
            pAgente[4].setAlignment(Paragraph.ALIGN_LEFT);

            // creating separators
            LineSeparator separador = new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -2);

            // Datos fijos
            Paragraph pPelayo[] = new Paragraph[5];
            pPelayo[0] = new Paragraph();
            pPelayo[0].add("PELAYO VIDA");
            pPelayo[0].setAlignment(Paragraph.ALIGN_RIGHT);
            pPelayo[1] = new Paragraph();
            pPelayo[1].add("CL SANTA ENGRACIA 69");
            pPelayo[1].setAlignment(Paragraph.ALIGN_RIGHT);
            pPelayo[2] = new Paragraph();
            pPelayo[2].add("28010  MADRID");
            pPelayo[2].setAlignment(Paragraph.ALIGN_RIGHT);
            pPelayo[3] = new Paragraph();
            pPelayo[3].add("MADRID");
            pPelayo[3].setAlignment(Paragraph.ALIGN_RIGHT);
            pPelayo[4] = new Paragraph();
            pPelayo[4].add("06422");
            pPelayo[4].setAlignment(Paragraph.ALIGN_RIGHT);

            // Fecha
            Paragraph pFecha = new Paragraph();
            pFecha = new Paragraph("Madrid, a " + periodos.extraeFechaLarga());
            pFecha.setAlignment(Paragraph.ALIGN_RIGHT);

            // Lnea 1 de FACTURA
            Paragraph pFactura1 = new Paragraph();
            sFactura1 = "FACTURA: n factura ";
            sFactura1 += rsComisiones.getString("CodAgente") + " - ";
            sFactura1 += periodos.extraePeriodoMY("MM-YYYY");
            pFactura1 = new Paragraph(sFactura1);

            // Lnea 2 de FACTURA
            Paragraph pFactura2 = new Paragraph();
            sFactura2 = "Factura por la prestacin de servicios relativos a las operaciones ";
            sFactura2 += "de intermediacin de seguros realizadas para su entidad del mes de ";
            sFactura2 += periodos.extraePeriodoMY("MM YYYY");
            ;
            pFactura2 = new Paragraph(sFactura2);

            // Datos Econmicos
            float[] anchuras = { 5f, 2f };
            PdfPTable table = new PdfPTable(anchuras);
            table.getDefaultCell().setBorder(0);

            // Tipo de letra para la tabla
            Font font = new Font(Font.FontFamily.COURIER, 11, Font.NORMAL);

            PdfPCell celda = new PdfPCell();

            celda = new PdfPCell(new Phrase("Comisiones pagadas", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(celda);

            celda = new PdfPCell(
                    new Phrase(Double.toString(rsComisiones.getDouble("TotalComisiones")) + " ", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase("Otros conceptos", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase(" ", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase(
                    "Retencin (" + Double.toString(rsComisiones.getDouble("RetencionPorcentaje")) + "%)",
                    font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(celda);

            Double dblRetencion = rsComisiones.getDouble("TotalComisiones")
                    * (rsComisiones.getDouble("RetencionPorcentaje") / 100);
            celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(dblRetencion) + " ", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase("Conceptos no sujetos", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase(" ", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(celda);

            celda = new PdfPCell(new Phrase("Total a pagar", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(celda);

            Double dblTotalPagar = rsComisiones.getDouble("TotalComisiones") - dblRetencion;
            celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(dblTotalPagar) + " ", font));
            celda.setBorder(Rectangle.NO_BORDER);
            celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(celda);

            // Literal: Operacin exenta de IVA
            Paragraph pColetilla = new Paragraph();
            pColetilla.add("Operacin exenta de IVA");

            // Aadimos los prrafos al Documento
            for (int i = 0; i < 5; i++)
                documento.add(pAgente[i]);

            documento.add(new Paragraph(" "));
            documento.add(separador);

            for (int i = 0; i < 5; i++)
                documento.add(pPelayo[i]);

            documento.add(new Paragraph(" "));

            documento.add(pFecha);
            documento.add(new Paragraph(" "));

            documento.add(pFactura1);
            documento.add(separador);
            documento.add(pFactura2);

            // Agregamos la tabla al documento    
            documento.add(new Paragraph(" "));
            documento.add(table);

            documento.add(new Paragraph(" "));
            documento.add(new Paragraph(" "));
            documento.add(pColetilla);
            documento.newPage();
        }
        documento.close();
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:comisionesafis.informes.FacturasComisionesAgentesPie.java

@Override
public void onEndPage(PdfWriter writer, Document document) {

    Font font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_LEFT,
            new Phrase("FacturasAgentes", font), 100, 80, 0);
}

From source file:comisionesafis.informes.LiquidacionComisiones.java

public boolean generar() {

    // Abrimos el fichero de comisiones
    String sSQL = "";
    Statement stmt;/*from  www.j a  va  2  s.  c om*/
    ResultSet rsAgentes;
    ResultSet rsRecibos;
    PdfPCell celda;
    boolean cabeceraColumnas;
    int filasPorPagina = 0;
    int fila = 0;
    PdfPTable table;
    Double dblTotal = 0.0;

    // Generamos la sentencia de Seleccin de Datos
    try {

        // Generamos el PDF
        Document documento = new Document(PageSize.A4, 80, 80, 50, 50);
        FileOutputStream salida = new FileOutputStream("LiquidacionComisiones.pdf");
        PdfWriter writer = PdfWriter.getInstance(documento, salida);
        writer.setInitialLeading(0);

        //  Obtenemos una instancia de nuestro manejador de eventos
        LiquidacionComisionesPie pie = new LiquidacionComisionesPie();
        //Asignamos el manejador de eventos al escritor.
        writer.setPageEvent(pie);

        // Abrimos el Documento
        documento.open();

        // SELECT para extraer todos los cdigos de los agentes con Recibos
        sSQL = "SELECT DISTINCT (CodAgente) AS Agente ";
        sSQL += "  FROM ResumenComisiones";
        sSQL += " ORDER BY CodAgente";
        stmt = conexion.createStatement();
        rsAgentes = stmt.executeQuery(sSQL);

        while (rsAgentes.next()) {

            if (sumaComisiones(rsAgentes.getString("Agente")) != 0) {
                paginaNum = 0;
                printCabecera1(documento);
                printCabeceraPelayo(documento);
                printCabecera2(documento, rsAgentes);

                // SELECT para extraer todos los Recibos de un agente
                sSQL = "SELECT * ";
                sSQL += "  FROM Recibos";
                sSQL += " WHERE CodAgente = '" + rsAgentes.getString("Agente") + "'";
                stmt = conexion.createStatement();
                rsRecibos = stmt.executeQuery(sSQL);

                //                if(rsAgentes.getString("Agente").equals("10803")){
                //                    System.out.println("");
                //                }

                // Creamos la tabla formateada
                table = creaTabla();

                cabeceraColumnas = true;
                filasPorPagina = 42;
                dblTotal = 0.0;
                while (rsRecibos.next()) {
                    if (Double.parseDouble(rsRecibos.getString("ImpComision")) != 0) {
                        if (fila >= filasPorPagina) {
                            // Salto de pgina
                            // Imprimimos el contenido de la tabla
                            documento.add(table);
                            documento.newPage();
                            table = creaTabla();
                            saltoDePagina(documento, table, rsAgentes);
                            fila = 1;
                            filasPorPagina = 47;
                        } else if (cabeceraColumnas) {
                            // Primera pgina
                            printCabeceraColumnas(table);
                            cabeceraColumnas = false;
                            fila = 1;
                        }
                        Font font = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
                        celda = new PdfPCell(new Phrase(rsRecibos.getString("NPoliza"), font));
                        celda.setBorder(Rectangle.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
                        table.addCell(celda);
                        celda = new PdfPCell(
                                new Phrase(Fechas.fechaVencimiento(rsRecibos.getString("Fecha")), font));
                        celda.setBorder(Rectangle.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
                        table.addCell(celda);
                        celda = new PdfPCell(new Phrase(fondoRecibo(rsRecibos.getString("Descripcion")), font));
                        celda.setBorder(Rectangle.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
                        table.addCell(celda);
                        celda = new PdfPCell(new Phrase(rsRecibos.getString("Importe"), font));
                        celda.setBorder(Rectangle.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
                        table.addCell(celda);
                        celda = new PdfPCell(new Phrase(Numeros.formateaDosDecimales(
                                Double.parseDouble(rsRecibos.getString("ImpComision"))), font));
                        celda.setBorder(Rectangle.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
                        table.addCell(celda);
                        dblTotal += Double.parseDouble(rsRecibos.getString("ImpComision"));
                        fila++;
                    }
                }
                if (fila >= filasPorPagina - 5) {
                    documento.add(table);
                    documento.newPage();
                    table = creaTabla();
                }
                printResumenContable(table, dblTotal, rsAgentes.getString("Agente"));
                documento.add(table);
                documento.newPage();
            }
        }
        documento.close();
        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:comisionesafis.informes.LiquidacionComisiones.java

private void printCabecera2(Document documento, ResultSet rsAgentes) {

    String sSQL = "";
    Statement stmt;/*from  w ww. ja va 2  s.  c o  m*/
    ResultSet rsDatosAgente;

    try {

        // SELECT para extraer todos los cdigos de los agentes con Recibos
        sSQL = "SELECT * ";
        sSQL += "  FROM Agentes";
        sSQL += " WHERE CodAgente='" + rsAgentes.getString("Agente") + "'";
        stmt = conexion.createStatement();
        rsDatosAgente = stmt.executeQuery(sSQL);

        if (!rsDatosAgente.next()) {
            // Este error no debera darse
            System.out.println("Error: No hay datos para el agente " + rsAgentes.getString("Agente"));
            return;
        }

        // Generamos la cabecera
        //Font fuenteCabecera = new Font(Font.FontFamily.COURIER, 8, Font.NORMAL);
        float[] anchuras = { 3f, 1f, 5f };
        PdfPTable table1 = new PdfPTable(anchuras);

        // Tipo de letra para la tabla
        Font font = new Font(Font.FontFamily.COURIER, 9, Font.NORMAL);

        PdfPCell celda = new PdfPCell();

        // Sucursal/Delegacin
        celda = new PdfPCell(new Phrase("SUCURSAL/DELEGACIN", font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        celda = new PdfPCell(new Phrase("02", font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        celda = new PdfPCell(new Phrase("PELAYO MONDIALE VIDA", font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        // No tenemos estos datos. Me pide Fernando que los quite
        //            // Inspeccin
        //            celda = new PdfPCell(new Phrase("INSPECCIN",font));
        //            celda.setBorder(Rectangle.NO_BORDER);
        //            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table1.addCell(celda);
        //
        //            celda = new PdfPCell(new Phrase("000001",font));
        //            celda.setBorder(Rectangle.NO_BORDER);
        //            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table1.addCell(celda);
        //
        //            celda = new PdfPCell(new Phrase("ACUERDO DE DISTRIBUCIN",font));
        //            celda.setBorder(Rectangle.NO_BORDER);
        //            celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        //            table1.addCell(celda);

        // Agente
        celda = new PdfPCell(new Phrase("AGENTE", font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        celda = new PdfPCell(new Phrase(rsDatosAgente.getString("CodAgente"), font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        celda = new PdfPCell(new Phrase(rsDatosAgente.getString("Nombre"), font));
        celda.setBorder(Rectangle.NO_BORDER);
        celda.setHorizontalAlignment(Element.ALIGN_LEFT);
        table1.addCell(celda);

        documento.add(table1);

    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

}