Example usage for com.itextpdf.layout Document add

List of usage examples for com.itextpdf.layout Document add

Introduction

In this page you can find the example usage for com.itextpdf.layout Document add.

Prototype

@Override
    public Document add(IBlockElement element) 

Source Link

Usage

From source file:controller.ReporteFechaController.java

private void generaTablaAsistencia(Document doc) throws IOException, RemoteException, NotBoundException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<Asistencia> asist = inter.asistenciaPorRangoDeFecha(
            from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE),
            to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (Asistencia o : asist) {
        ls.add(o.getContrato());/*from  ww w .j  av  a  2s. c o m*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (Asistencia a : asist) {
        inv += Integer.parseInt(a.getInvitados());
    }

    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(asist.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    ArrayList<String> l = new ArrayList<>(
            Arrays.asList("Cedula", "Cliente", "Contrato", "Plan", "Fecha", "Invitados", "Inv Adicionales"));
    tc = generaCabezera(l);
    doc.add(tc);
    for (Asistencia a : asist) {
        generaClienteAsistencia(doc, a);
        white *= -1;
    }

}

From source file:controller.ReporteFechaController.java

private void generaTablaAperturaMesas(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<ReporteMesa> open = inter.apMesasFechas(from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE),
            to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (ReporteMesa o : open) {
        ls.add(o.getContrato());/*w w  w  . j  a v  a2 s. co m*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (ReporteMesa r : open) {
        inv += Integer.parseInt(r.getInvitados());
    }
    if (open.size() == 0) {
        inv = 0;
        invadd = 0;
    }
    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(open.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    List<String> l = Arrays.asList("Usuario", "Cliente", "Cedula", "Contrato", "Plan", "Fecha", "Invitados",
            "Inv. Adicional");
    tc = generaCabezera(l);
    doc.add(tc);
    for (ReporteMesa r : open) {
        generaClienteApMesa(doc, r);
        white *= -1;
    }

}

From source file:controller.ReporteFechaController.java

private void generaTablaPases(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<ReporteMesa> open = inter.pasesFechas(from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE),
            to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (ReporteMesa o : open) {
        ls.add(o.getContrato());/*from w ww .java  2 s  .c  o  m*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (ReporteMesa r : open) {
        inv += Integer.parseInt(r.getInvitados());
    }
    if (open.size() == 0) {
        inv = 0;
        invadd = 0;
    }
    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(open.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    List<String> l = Arrays.asList("Usuario", "Cliente", "Cedula", "Contrato", "Plan", "Fecha", "Invitados",
            "Inv. Adicional");
    tc = generaCabezera(l);
    doc.add(tc);
    for (ReporteMesa r : open) {
        generaClienteApMesa(doc, r);
        white *= -1;
    }
}

From source file:controller.ReporteFechaController.java

private void generaTablaAutorizaciones(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<Autorizado> open = inter.AutorizadoFechas(
            from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE),
            to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (Autorizado o : open) {
        ls.add(o.getContrato());/*from  www  . j  av a 2  s  . c om*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (Autorizado r : open) {
        inv += Integer.parseInt(r.getInvitados());
    }
    if (open.size() == 0) {
        inv = 0;
        invadd = 0;
    }
    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(open.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    List<String> l = Arrays.asList("Usuario", "Autorizado", "Cliente", "Cedula", "Contrato", "Plan", "Fecha",
            "Invitados", "Inv. Adicional");
    tc = generaCabezera(l);
    doc.add(tc);
    for (Autorizado r : open) {
        generaClienteAutorizado(doc, r);
        white *= -1;
    }
}

From source file:controller.ReporteFechaController.java

private void generaTablaAcceso(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    Table tc;/*from   ww  w. j  av  a2 s  .co  m*/
    ArrayList<Login> log = inter.getLogLogins();
    log.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())));
    List<String> l = Arrays.asList("Nombre", "Apellido", "Usuario", "Fecha", "Hora");
    tc = generaCabezera(l);
    doc.add(tc);
    for (Login ll : log) {
        generaLogin(doc, ll);
        white *= -1;
    }

}

From source file:controller.ReporteFechaController.java

private void generaTablaBusqueda(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    Table tc;//from  w ww  .j  a  v a 2  s  .  com
    ArrayList<Busqueda> log = inter.getAllSearch();
    log.removeIf(r -> !(LocalDate.parse(r.getFecha()).plusDays(1).isAfter(from.getValue())
            && LocalDate.parse(r.getFecha()).minusDays(1).isBefore(to.getValue())));
    List<String> l = Arrays.asList("Usuario", "Tipo", "Filtro", "Fecha", "Hora");
    tc = generaCabezera(l);
    doc.add(tc);
    for (Busqueda ll : log) {
        generaBusqueda(doc, ll);
        white *= -1;
    }
}

From source file:controller.ReporteMesController.java

public void generaPDF(ActionEvent evt)
        throws FileNotFoundException, MalformedURLException, IOException, RemoteException, NotBoundException {

    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasiscrud.oasisrimbd inter = (oasiscrud.oasisrimbd) reg.lookup("OasisSev");

    FileChooser file = new FileChooser();
    file.getExtensionFilters().add(new FileChooser.ExtensionFilter("Documento PDF", " *.PDF"));
    File f = file.showSaveDialog(null);
    PdfWriter writer = new PdfWriter(f.getAbsolutePath());

    PdfDocument pdf = new PdfDocument(writer);
    pdf.setDefaultPageSize(PageSize.LETTER.rotate());

    Document document = new Document(pdf);

    Cell c;//w  w  w . j  av a2  s .c  o  m
    Table tc;
    Paragraph p = new Paragraph();
    Image img = new Image(ImageDataFactory.create(getClass().getResource("/images/pdf-logo.png")));
    img.setHorizontalAlignment(HorizontalAlignment.CENTER);
    document.add(img);

    document.add(new Paragraph("\n"));

    tc = new Table(1);
    tc.addCell(generaCabezera("Reporte del mes " + cbmes.getSelectionModel().getSelectedItem() + " del ao "
            + cbano.getSelectionModel().getSelectedItem()));
    document.add(tc);

    generaTitulo(document, "Detalles de asistencias General");
    generaTablaAsistencia(document);
    pdf.addNewPage();
    document.add(new AreaBreak());
    generaTitulo(document, "Detalles de Aperturas de mesas");
    generaTablaAperturaMesas(document);
    pdf.addNewPage();
    document.add(new AreaBreak());
    generaTitulo(document, "Detalles de Pases generados");
    generaTablaPases(document);
    pdf.addNewPage();
    document.add(new AreaBreak());
    generaTitulo(document, "Detalles de Autorizaciones");
    generaTablaAutorizaciones(document);
    pdf.addNewPage();
    document.add(new AreaBreak());
    generaTitulo(document, "Detalles de accesos al sistema");
    generaTablaAcceso(document);
    pdf.addNewPage();
    document.add(new AreaBreak());
    generaTitulo(document, "Detalles de busquedas en el sistema");
    generaTablaBusqueda(document);
    document.close();
    System.out.println(f.getAbsolutePath());
    close(evt);
}

From source file:controller.ReporteMesController.java

private void generaTablaAsistencia(Document doc) throws IOException, RemoteException, NotBoundException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<Asistencia> asist = inter.asistenciaPorMes((cbmes.getSelectionModel().getSelectedIndex() + 1));

    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (Asistencia o : asist) {
        ls.add(o.getContrato());/*  w w  w  .  j  ava2s .  c o m*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha())
            .getMonthValue() == (cbmes.getSelectionModel().getSelectedIndex() + 1)
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (Asistencia a : asist) {
        inv += Integer.parseInt(a.getInvitados());
    }

    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(asist.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    ArrayList<String> l = new ArrayList<>(
            Arrays.asList("Cedula", "Cliente", "Contrato", "Plan", "Fecha", "Invitados", "Inv Adicionales"));
    tc = generaCabezera(l);
    doc.add(tc);
    for (Asistencia a : asist) {
        generaClienteAsistencia(doc, a);
        white *= -1;
    }

}

From source file:controller.ReporteMesController.java

private void generaTablaAperturaMesas(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<ReporteMesa> open = inter.apMesasmes((cbmes.getSelectionModel().getSelectedIndex() + 1));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (ReporteMesa o : open) {
        ls.add(o.getContrato());//from   ww w.  j a  va2s . c  o m
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha())
            .getMonthValue() == (cbmes.getSelectionModel().getSelectedIndex() + 1)
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (ReporteMesa r : open) {
        inv += Integer.parseInt(r.getInvitados());
    }
    if (open.size() == 0) {
        inv = 0;
        invadd = 0;
    }
    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(open.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    List<String> l = Arrays.asList("Usuario", "Cliente", "Cedula", "Contrato", "Plan", "Fecha", "Invitados",
            "Inv. Adicional");
    tc = generaCabezera(l);
    doc.add(tc);
    for (ReporteMesa r : open) {
        generaClienteApMesa(doc, r);
        white *= -1;
    }

}

From source file:controller.ReporteMesController.java

private void generaTablaPases(Document doc) throws RemoteException, NotBoundException, IOException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    ArrayList<ReporteMesa> open = inter.pasesMes((cbmes.getSelectionModel().getSelectedIndex() + 1));
    ArrayList<Invitado> invad = inter.getInvitados();
    List<String> ls = new ArrayList<>();
    for (ReporteMesa o : open) {
        ls.add(o.getContrato());/*from   w w  w. ja va2  s . c  om*/
    }
    invad.removeIf(r -> !(LocalDate.parse(r.getFecha())
            .getMonthValue() == (cbmes.getSelectionModel().getSelectedIndex() + 1)
            && ls.contains(r.getContrato())));
    int inv = 0, invadd = invad.size();
    for (ReporteMesa r : open) {
        inv += Integer.parseInt(r.getInvitados());
    }
    if (open.size() == 0) {
        inv = 0;
        invadd = 0;
    }
    Table tc = new Table(2);
    Cell c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add("Numero de titulares");
    c.add("Numero de invitados");
    c.add("Numero de invitados Adicionales");
    c.add("\n");
    tc.addCell(c);
    c = new Cell();
    c.setFont(PdfFontFactory.createRegisteredFont("times-italic"));
    c.setBorder(Border.NO_BORDER);
    c.add("\n");
    c.add(Integer.toString(open.size()));
    c.add(Integer.toString(inv));
    c.add(Integer.toString(invadd));
    c.add("\n");
    tc.addCell(c);
    doc.add(tc);
    List<String> l = Arrays.asList("Usuario", "Cliente", "Cedula", "Contrato", "Plan", "Fecha", "Invitados",
            "Inv. Adicional");
    tc = generaCabezera(l);
    doc.add(tc);
    for (ReporteMesa r : open) {
        generaClienteApMesa(doc, r);
        white *= -1;
    }
}