<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
</dependency>
createPDF("./students.jasper");
with compiled jasper file
public static void createPDF(String jasperFile){
List studentList = new ArrayList<>();
studentList.add(new Student("Lisa", "Mayer"));
studentList.add(new Student("Patrick", "Huber"));
studentList.add(new Student("Werner", "Reiter"));
studentList.add(new Student("Bettina", "Gruber"));
studentList.add(new Student("Dominik", "Berner"));
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(studentList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperFile, new HashMap(), beanColDataSource);
JasperExportManager.exportReportToPdfFile(jasperPrint, "students.pdf"); // see attachment students.pdf
}
Using a program such as CuteFTP or PrimoPDF will allow you to create a PDF of any file that you can print, including images. You can download either of these programs at the following links.
PrimoPDF: http://www.primopdf.com
CutePDF page: http://www.cutepdf.com
After downloading and installing one of these, open the image in any image editor or viewer and print the file. When the print window opens, instead of selecting a printer, select either CuteFTP or PrimoPDF as your printer and click Ok. This will send that image to a .pdf file instead of your printer.
Adobe Acrobat Reader 8 must be installed on the server. After installation the PDF file type must be added to the search index.
Next steps:
1. Open your Search Settings.
2. Select File Types, click Add File Type.
3. Enter pdf in the text box and click OK.
4. Download the PDF icon from: http://www.iconarchive.com/category/application/adobe-family-icons-by-de..., give the icon a name.
5. Save the icon in c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES, edit the Docicon.xml file to include the PDF icon.
6. Navigate to c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML.
7. Open the DOCICON.XML file in Notepad.
8. Add an entry for the PDF icon ‘Mapping Key=”pdf” Value=”pdficon.gif” /’ (replace the single quotes with angle brackets).
9. Save and close the file, right click the file, and select ‘Properties’.
10. Select the ‘Security Tab’ then click ‘Add’, add ‘Read’ and ‘Read & Execute’ permissions ‘Domain Users’.
use pdf:writer gem:
http://ruby-pdf.rubyforge.org/pdf-writer/
usage:
pdf = PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.text "Halli hallo!", :font_size => 72, :justification => :center
pdf.save_as("hello.pdf")