Statistics
| Revision:

root / hci / trunk / eneraptor-web-app / grails-app / views / pdf / demo3.gsp @ 50

History | View | Annotate | Download (2.5 KB)

1
<html>
2
  <head>
3
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
4
    <meta name="layout" content="main" />
5
    <title>Simple PDF demo2</title>
6
    <style>
7
      .sample_table {
8
        width:60%;
9
        background-color:#b2b2b2;
10
      }
11
      .sample_table th {
12
        text-align:center;
13
        text-decoration:underline;
14
      }
15
      .sample_table td {
16
        padding:7px;
17
        background-color: #fff;
18
      }
19
      .small_text {
20
        font-size:8pt;
21
      }
22
    </style>
23
  </head>
24
  <body>
25
    <h1>Sample PDF Output</h1>
26
    <h2>This is simple HTML</h2>
27
    <h2 style='color:red'>this has inline CSS</h2>
28
    
29
    <h3>Here is some data passed from the contorller...</h3>
30
    <p>Information gathered from the controller: ${randomString}</p>
31
    
32
    <h3>Here is some information sent in the URL and handled by a controller (get variables):</h3>
33
    <table class="sample_table">
34
      <thead>
35
        <tr>
36
          <th>ID</th>
37
          <th>Name</th>
38
          <th>Age</th>
39
        </tr>
40
      </thead>
41
      <tbody>
42
        <tr>
43
          <td>${id}</td>
44
          <td>${name}</td>
45
          <td>${age}</td>
46
        </tr>
47
        <tr>
48
          <td colspan="3" class="small_text">styled with css...</td>
49
        </tr>
50
      </tbody>
51
    </table> 
52
    
53
    <h3>Here is some information gathered from a form and handled by a controller (post variables):</h3>
54
    <p>Favorite food: ${pdf?.food}</p>
55
    <p>Favorite food: ${pdf?.food.toString()}</p>
56
    <p>Hometown: ${pdf?.hometown}</p> 
57
    
58
    <p>${pdf}</p>
59
    
60
    <p>Images with relative URL's are automatically resolved by the the modified version of XHTMLrenderer included with the plugin</p>
61
    <img src="<g:resource dir='images' file='laptop.jpg' />" alt="laptop" title="laptop" />
62
    
63
    <p>Images with absolute URI's also do just fine:</p>
64
    <img src="http://system76.com/images/nb1_front_med.jpg" alt="laptop2" title="laptop2" />
65
    
66
    <p><strong>Hint:</strong> One way to style gsp's that you intend to make into pdf's is to have two seperate style sheets one for media="print" and one for media="screen". The print style sheet will be used to style the PDF, and if PDF generation fails you will get a styled HTML view that isn't all weird because of fonts sized in pt and such.</p>
67
    
68
    <p>Varialbles passed into gsp that the plugin will render as PDF need to start with pdf. so for example the form field name was hometown and to reference that varialbe here we needed {pdf.hometown}</p>
69
    <code>
70
      ${content}
71
    </code>
72
  </body>
73
</html>