use of jgnash.report.pdf.Report in project jgnash by ccavanaugh.
the class PDFBoxTableTest method crossTabReportTest.
@Test
void crossTabReportTest() throws IOException {
Path tempPath = null;
Path tempRasterPath = null;
try (final Report report = new SimpleReport()) {
tempPath = Files.createTempFile("pdfTest", ".pdf");
tempRasterPath = Files.createTempFile("pdfTest", ".png");
final float padding = 2.5f;
report.setTableFont(PDType1Font.COURIER);
report.setHeaderFont(PDType1Font.HELVETICA_BOLD);
report.setCellPadding(padding);
report.setBaseFontSize(9);
report.setForceGroupPagination(true);
final PageFormat pageFormat = (PageFormat) report.getPageFormat().clone();
pageFormat.setOrientation(PageFormat.LANDSCAPE);
report.setPageFormat(pageFormat);
report.setFooterFont(PDType1Font.TIMES_ITALIC);
report.setEllipsis("…");
assertEquals(2, GroupInfo.getGroups(new CrossTabTestReport()).size());
report.addTable(new CrossTabTestReport());
report.addFooter();
report.saveToFile(tempPath);
assertTrue(report.isLandscape());
assertEquals(padding, report.getCellPadding());
assertTrue(Files.exists(tempPath));
// Create a PNG file
final BufferedImage bim = report.renderImage(0, 300);
ImageIOUtil.writeImage(bim, tempRasterPath.toString(), 300);
assertTrue(Files.exists(tempRasterPath));
} catch (final IOException e) {
e.printStackTrace();
} finally {
if (tempPath != null) {
Files.deleteIfExists(tempPath);
}
if (tempRasterPath != null) {
Files.deleteIfExists(tempRasterPath);
}
}
}
use of jgnash.report.pdf.Report in project jgnash by ccavanaugh.
the class PDFBoxTableTest method basicReportTest.
@Test
void basicReportTest() throws IOException {
Path tempPath = null;
Path tempRasterPath = null;
try (final Report report = new SimpleReport()) {
tempPath = Files.createTempFile("pdfTest", ".pdf");
tempRasterPath = Files.createTempFile("pdfTest", ".png");
final float padding = 2.5f;
report.setTableFont(PDType1Font.COURIER);
report.setHeaderFont(PDType1Font.HELVETICA_BOLD);
report.setCellPadding(padding);
report.setBaseFontSize(9);
final PageFormat pageFormat = ReportPrintFactory.getDefaultPage();
pageFormat.setOrientation(PageFormat.LANDSCAPE);
report.setPageFormat(pageFormat);
report.setFooterFont(PDType1Font.TIMES_ITALIC);
report.setEllipsis("…");
assertEquals(1, GroupInfo.getGroups(new BasicTestReport()).size());
// assertEquals(80, ((GroupInfo) GroupInfo.getGroups(new BasicTestReport()).toArray()[0]).rows);
report.addTable(new BasicTestReport());
report.addFooter();
report.saveToFile(tempPath);
assertTrue(report.isLandscape());
assertEquals(padding, report.getCellPadding());
assertTrue(Files.exists(tempPath));
// Create a PNG file
final BufferedImage bim = report.renderImage(0, 300);
ImageIOUtil.writeImage(bim, tempRasterPath.toString(), 300);
assertTrue(Files.exists(tempRasterPath));
} catch (final IOException e) {
e.printStackTrace();
} finally {
if (tempPath != null) {
Files.deleteIfExists(tempPath);
}
if (tempRasterPath != null) {
Files.deleteIfExists(tempRasterPath);
}
}
}
Aggregations