# Centrar en el reporte

```java
Paragraph p = new Paragraph("PROGRAMACION DE FLOTA VEHICULAR",
                    FontFactory.getFont("arial", // fuente
                            12, // tamaño
                            Font.BOLD));
            p.setAlignment(Element.ALIGN_CENTER);
```

![](/files/-LoLWS3zQKCipjKSMTP3)

```java
 public void imprimir() {

//        com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.LETTER);
        com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.A4.rotate());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            PdfWriter.getInstance(document, baos);
            //METADATA

            document.open();

            Paragraph p = new Paragraph("PROGRAMACION DE FLOTA VEHICULAR",
                    FontFactory.getFont("arial", // fuente
                            12, // tamaño
                            Font.BOLD));
            p.setAlignment(Element.ALIGN_CENTER);
            document.add(p);
            //document.add(new Paragraph(" PROGRAMACION DE FLOTA VEHICULAR \n"));

            DateFormat formatter = new SimpleDateFormat("dd/MM/yy '-' hh:mm:ss:");
            Date currentDate = new Date();
            String date = formatter.format(currentDate);
            document.add(new Paragraph("Fecha Generado: " + date));
            document.add(new Paragraph("\n"));

            PdfPTable table = new PdfPTable(7);

//                  table.setTotalWidth(new float[]{ 20,72, 110, 95, 170, 72 });
            table.setTotalWidth(new float[]{20, 100, 85, 85, 225, 72, 110});
            table.setLockedWidth(true);

            PdfPCell cell = new PdfPCell(new Paragraph("id",
                    FontFactory.getFont("arial", // fuente
                            12, // tamaño
                            Font.BOLD)));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);

            cell.setColspan(1);
            table.addCell(cell);

            //  cell = new PdfPCell(new Paragraph("ID", FontFactory.getFont("arial", 8, Font.BOLD)));
            table.addCell("fechapartida");
            table.addCell("dia");
            table.addCell("unidad");
            table.addCell("mision");

            table.addCell("conductor");

            table.addCell("placa");

            for (ProgramacionVehicular pv : programacionVehicular) {
                String fechaPartida = formatter.format(pv.getFechahorasalida());
                PdfPCell cellId = new PdfPCell(new Paragraph(pv.getIdviaje().toString(), FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellId);
                PdfPCell cellFechaPartida = new PdfPCell(new Paragraph(fechaPartida, FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellFechaPartida);

                PdfPCell cellNombredia = new PdfPCell(new Paragraph(pv.getNombredia(), FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellNombredia);

                PdfPCell cellUnidad = new PdfPCell(new Paragraph(pv.getUnidad(), FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellUnidad);
                PdfPCell cellMision = new PdfPCell(new Paragraph(pv.getMision(), FontFactory.getFont("arial", 9, Font.NORMAL)));

                table.addCell(cellMision);
//                table.addCell(pv.getMision());

                PdfPCell cellConductor = new PdfPCell(new Paragraph(pv.getConductor(), FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellConductor);

                PdfPCell cellPlaca = new PdfPCell(new Paragraph(pv.getPlaca(), FontFactory.getFont("arial", 9, Font.NORMAL)));
                table.addCell(cellPlaca);

            }
            document.add(table);
        } catch (Exception ex) {
            System.out.println("Error " + ex.getMessage());
        }
        document.close();
        FacesContext context = FacesContext.getCurrentInstance();
        Object response = context.getExternalContext().getResponse();
        if (response instanceof HttpServletResponse) {
            HttpServletResponse hsr = (HttpServletResponse) response;
            hsr.setContentType("application/pdf");
            hsr.setHeader("Contentdisposition", "attachment;filename=report.pdf");
            //        hsr.setHeader("Content-disposition", "attachment");
            hsr.setContentLength(baos.size());
            try {
                ServletOutputStream out = hsr.getOutputStream();
                baos.writeTo(out);
                out.flush();
            } catch (IOException ex) {
                System.out.println("Error:  " + ex.getMessage());
            }
            context.responseComplete();
        }
    }

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/reportes/pdfbox-reportes/centrar-en-el-reporte.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
