1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package ar.com.fdvs.dj.test;
31
32
33 import java.util.Date;
34
35 import net.sf.jasperreports.view.JasperViewer;
36 import ar.com.fdvs.dj.domain.DynamicReport;
37 import ar.com.fdvs.dj.domain.Style;
38 import ar.com.fdvs.dj.domain.builders.FastReportBuilder;
39 import ar.com.fdvs.dj.domain.builders.StyleBuilder;
40 import ar.com.fdvs.dj.domain.constants.Font;
41
42 public class FontReportTest extends BaseDjReportTest {
43
44 public DynamicReport buildReport() throws Exception {
45
46
47 Font font = new Font(28,"Colonna MT","/fonts/COLONNA.TTF",Font.PDF_ENCODING_Identity_H_Unicode_with_horizontal_writing,true);
48 Style titleStyle = new StyleBuilder(false).setFont(font).build();
49
50 /***
51 * Creates the DynamicReportBuilder and sets the basic options for
52 * the report
53 */
54 FastReportBuilder drb = new FastReportBuilder();
55 drb.addColumn("State", "state", String.class.getName(),30)
56 .addColumn("Branch", "branch", String.class.getName(),30)
57 .addColumn("Product Line", "productLine", String.class.getName(),50)
58 .addColumn("Item", "item", String.class.getName(),50)
59 .addColumn("Item Code", "id", Long.class.getName(),30,true)
60 .addColumn("Quantity", "quantity", Long.class.getName(),60,true)
61 .addColumn("Amount", "amount", Float.class.getName(),70,true)
62 .addGroups(2)
63 .setTitle("November 2006 sales report")
64 .setTitleStyle(titleStyle)
65 .setSubtitle("This report was generated at " + new Date())
66
67 .setUseFullPageWidth(true);
68
69 DynamicReport dr = drb.build();
70
71 return dr;
72 }
73
74 public static void main(String[] args) throws Exception {
75 FontReportTest test = new FontReportTest();
76 test.testReport();
77 JasperViewer.viewReport(test.jp);
78
79 }
80
81 }