Hi, this is the initial post of a series where i’ll be publishing some samples showing how to generate pdf documents with the popular library JasperReports using the Java API.
Sample code to generate blank pdf document.
- jasperreports-hello-world-pdf – a sample to generate blank pdf
- jasperreports-pdf-image – a sample to generate pdf with an image
- jasperreports-pdf-table – a sample to generate a table
*All running tests create a pdf document in the hard-coded path set and hang the current java process.While the process is running you can preview the pdf with your favourite tool.
When you stop this process, the document is deleted. This is the behaviour.
‘jasperreports-hello-world-pdf‘ – is the simplest sample where a blank pdf is generated. Run the main class ‘JasperReportsApplication’ and adjust the directory where the pdf file is created to fit your environment.
‘jasperreports-pdf-image‘ – this sample shows how to insert an images in several ways inside a pdf.
Run the tests declared in ‘ImageIT’ and adjust the directory where the pdf file is created to fit your environment.
jasperreports-pdf-table‘ – this sample shows how to fill a table with data inside a pdf using a ‘JRBeanCollectionDataSource’.
Run the test in ‘TableIT’ and adjust the directory where the pdf file is created to fit your environment.