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.ReporteDiarioController.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.apMesasDiario(date.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  w w  .j av a2s  . c  o  m
    }
    invad.removeIf(r -> !(r.getFecha().equals(date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE))
            && 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.ReporteDiarioController.java

private void generaClienteApMesa(Document doc, ReporteMesa asist)
        throws IOException, RemoteException, NotBoundException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    Cliente c = inter.clientePorContrato(asist.getContrato());
    ArrayList<Invitado> inv = inter.getInvitados();
    inv.removeIf(r -> !r.getContrato().equals(asist.getContrato()));
    Table tc = new Table(8);
    if (white < 0) {
        tc.setBackgroundColor(Color.LIGHT_GRAY);
    }/*from   w w  w  .  j  a va 2s.  c o  m*/
    tc.addCell(generaCeldaNormal(asist.getUsuario()));
    tc.addCell(generaCeldaNormal(c.getNombre()));
    tc.addCell(generaCeldaNormal(c.getCedula()));
    tc.addCell(generaCeldaNormal(asist.getContrato()));
    tc.addCell(generaCeldaNormal(c.getPlan()));
    tc.addCell(generaCeldaNormal(asist.getFecha()));
    tc.addCell(generaCeldaNormal(asist.getInvitados()));
    tc.addCell(generaCeldaInvitados(inv));
    doc.add(tc);
}

From source file:controller.ReporteDiarioController.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.pasesDiario(date.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  w  w .jav a2s.c  om
    }
    invad.removeIf(r -> !(r.getFecha().equals(date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE))
            && 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.ReporteDiarioController.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
            .AutorizadoDiario(date.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 ww  w  .jav a 2  s . c om*/
    }
    invad.removeIf(r -> !(r.getFecha().equals(date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE))
            && 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.ReporteDiarioController.java

private void generaClienteAutorizado(Document doc, Autorizado asist)
        throws IOException, RemoteException, NotBoundException {
    Registry reg = LocateRegistry.getRegistry(host, 27019);
    oasisrimbd inter = (oasisrimbd) reg.lookup("OasisSev");
    Cliente c = inter.clientePorContrato(asist.getContrato());
    ArrayList<Invitado> inv = inter.getInvitados();
    inv.removeIf(r -> !r.getContrato().equals(asist.getContrato()));
    Table tc = new Table(9);
    if (white < 0) {
        tc.setBackgroundColor(Color.LIGHT_GRAY);
    }// ww  w  .  ja v a 2s  .  co  m
    tc.addCell(generaCeldaNormal(asist.getUsuario()));
    tc.addCell(generaCeldaNormal(asist.getAutorizado()));
    tc.addCell(generaCeldaNormal(c.getNombre()));
    tc.addCell(generaCeldaNormal(c.getCedula()));
    tc.addCell(generaCeldaNormal(asist.getContrato()));
    tc.addCell(generaCeldaNormal(c.getPlan()));
    tc.addCell(generaCeldaNormal(asist.getFecha()));
    tc.addCell(generaCeldaNormal(asist.getInvitados()));
    tc.addCell(generaCeldaInvitados(inv));
    doc.add(tc);
}

From source file:controller.ReporteDiarioController.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 w w w  .ja  v a  2s.c  o m*/
    ArrayList<Login> log = inter.getLogLogins();
    log.removeIf(l -> !l.getFecha().equals(date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)));
    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.ReporteDiarioController.java

private void generaLogin(Document doc, Login ll) throws IOException {
    Table tc = new Table(5);
    if (white < 0) {
        tc.setBackgroundColor(Color.LIGHT_GRAY);
    }/*from  w  w w . j  av  a 2s.c o  m*/
    tc.addCell(generaCeldaNormal(ll.getNombre()));
    tc.addCell(generaCeldaNormal(ll.getApellido()));
    tc.addCell(generaCeldaNormal(ll.getUsuario()));
    tc.addCell(generaCeldaNormal(ll.getFecha()));
    tc.addCell(generaCeldaNormal(ll.getHora()));
    doc.add(tc);
}

From source file:controller.ReporteDiarioController.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  2s.co  m
    ArrayList<Busqueda> log = inter.getAllSearch();
    log.removeIf(l -> !l.getFecha().equals(date.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)));
    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.ReporteDiarioController.java

private void generaBusqueda(Document doc, Busqueda ll) throws IOException {
    Table tc = new Table(5);
    if (white < 0) {
        tc.setBackgroundColor(Color.LIGHT_GRAY);
    }//from w  w  w.j a va2 s  . c  om
    tc.addCell(generaCeldaNormal(ll.getUsuario()));
    tc.addCell(generaCeldaNormal(ll.getTipo()));
    tc.addCell(generaCeldaNormal(ll.getFiltro()));
    tc.addCell(generaCeldaNormal(ll.getFecha()));
    tc.addCell(generaCeldaNormal(ll.getHora()));
    doc.add(tc);
}

From source file:controller.ReporteFechaController.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  a 2s.  c  om*/
    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 desde el dia "
            + from.getValue().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()) + " "
            + from.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE) + " hasta el dia "
            + to.getValue().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.getDefault()) + " "
            + to.getValue().format(DateTimeFormatter.ISO_LOCAL_DATE)));
    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);
}