code: public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
          try {
              Document document = new Document();
              PdfWriter.getInstance(document, out);
              if (columns == null)
              {
                  if (rows.size() > 0) return;
                  columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                      @Override
                      public Object transform(final Object input) {
                          return new ColumnDef()
                          {{
                                  setName((String)input);
                              }};
                      }
                  }));
              }
                  if (columns.size() > 14)
                      document.setPageSize(PageSize.A1);
                  else if (columns.size() > 10)
                      document.setPageSize(PageSize.A2);
                  else if (columns.size() > 7)
                      document.setPageSize(PageSize.A3);
                  else
                      document.setPageSize(PageSize.A4);
              document.open();
              Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, BaseColor.BLACK);
              Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD, BaseColor.BLACK);
  
              int size = columns.size();
              PdfPTable table = new PdfPTable(size);
              for (ColumnDef column : columns)
              {
                  PdfPCell c1 = new PdfPCell(new Phrase(column.getName(), headerFont));
                  c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                  table.addCell(c1);
              }
              table.setHeaderRows(1);
              if (rows != null)
                  for (Map<String, Object> row : rows)
                  {
                      for (ColumnDef column : columns)
                      {
                          table.addCell(new Phrase(String.valueOf(row.get(column.getName())), font));
                      }
                  }
              document.add(table);
              document.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
docs: Takes the output and transforms it into a PDF file.
  @param out Output stream.
  @param rows Rows of data from reporting-core
  @param columns Columns to list on report