Mercurial > hg > soundsoftware-site
comparison vendor/plugins/rfpdf/.svn/text-base/README.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 513646585e45 |
children |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 FWIW - I am migrating my apps to Prawn and Prawnto | |
2 | |
1 = RFPDF Template Plugin | 3 = RFPDF Template Plugin |
2 | 4 |
3 A template plugin allowing the inclusion of ERB-enabled RFPDF template files. | 5 A template plugin allowing the inclusion of ERB-enabled RFPDF template files. |
4 | 6 |
5 == Example .rb method Usage | 7 == |
8 == | |
9 == TCPDF Version (The New or UTF8 Version) | |
10 == | |
11 == | |
6 | 12 |
7 In the controller, something like: | 13 If you are using HTML, it is recommended you install: |
8 | 14 |
9 def mypdf | 15 gem install -r htmlentities |
10 pdf = FPDF.new() | |
11 | 16 |
12 # | 17 TCPDF Documentation located at: |
13 # Chinese | |
14 # | |
15 pdf.extend(PDF_Chinese) | |
16 pdf.AddPage | |
17 pdf.AddBig5Font | |
18 pdf.SetFont('Big5','',18) | |
19 pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %') | |
20 icBig5 = Iconv.new('Big5', 'UTF-8') | |
21 pdf.Write(15, icBig5.iconv("宋体 should be working")) | |
22 send_data pdf.Output, :filename => "something.pdf", :type => "application/pdf" | |
23 end | |
24 | 18 |
25 == Example .rfdf Usage | 19 http://phpdocs.moodle.org/com-tecnick-tcpdf/TCPDF.html |
26 | 20 |
27 In the controller, something like: | 21 Example of simple use in .rhtml: |
28 | |
29 def mypdf | |
30 @options_for_rfpdf ||= {} | |
31 @options_for_rfpdf[:file_name] = "nice_looking.pdf" | |
32 end | |
33 | |
34 In the layout (make sure this is the only item in the layout): | |
35 <%= @content_for_layout %> | |
36 | |
37 In the view (mypdf.rfpdf): | |
38 | 22 |
39 <% | 23 <% |
40 pdf = FPDF.new() | 24 @pdf = TCPDF.new() |
41 # | 25 @pdf.SetMargins(15, 27, 15); |
42 # Chinese | 26 @pdf.AddPage(); |
43 # | 27 text_options = {:font => "freeserif"} |
44 pdf.extend(PDF_Chinese) | 28 @pdf.draw_text(15, 10, "text", {:font_size => 12, :font => "freeserif"}) |
45 pdf.AddPage | 29 %><%=@pdf.Output()%> |
46 pdf.AddBig5Font | |
47 pdf.SetFont('Big5','',18) | |
48 pdf.Write(5, '²{®É®ð·Å 18 C Àã«× 83 %') | |
49 icBig5 = Iconv.new('Big5', 'UTF-8') | |
50 pdf.Write(15, icBig5.iconv("宋体 should be working")) | |
51 | 30 |
52 # | 31 See the following files for sample of useage: |
53 # Japanese | |
54 # | |
55 pdf.extend(PDF_Japanese) | |
56 pdf.AddSJISFont(); | |
57 pdf.AddPage(); | |
58 pdf.SetFont('SJIS','',18); | |
59 pdf.Write(5,'9ÉñåéÇÃåˆäJÉeÉXÉgÇåoǃPHP 3.0ÇÕ1998îN6åéÇ…åˆéÆÇ…ÉäÉäÅ[ÉXÇ≥ÇÍNjǵÇΩÅB'); | |
60 icSJIS = Iconv.new('SJIS', 'UTF-8') | |
61 pdf.Write(15, icSJIS.iconv("これはテキストである should be working")) | |
62 | 32 |
63 # | 33 test_unicode.rfpdf |
64 # Korean | 34 utf8test.txt |
65 # | 35 logo_example.png |
66 pdf.extend(PDF_Korean) | |
67 pdf.AddUHCFont(); | |
68 pdf.AddPage(); | |
69 pdf.SetFont('UHC','',18); | |
70 pdf.Write(5,'PHP 3.0Àº 1998³â 6¿ù¿¡ °ø½ÄÀûÀ¸·Î ¸±¸®ÁîµÇ¾ú´Ù. °ø°³ÀûÀÎ Å×½ºÆ® ÀÌÈľà 9°³¿ù¸¸À̾ú´Ù.'); | |
71 icUHC = Iconv.new('UHC', 'UTF-8') | |
72 pdf.Write(15, icUHC.iconv("이것은 원본 이다")) | |
73 | 36 |
74 # | 37 FPDF users can migrate to TCPDF by changing the following from: |
75 # English | |
76 # | |
77 pdf.AddPage(); | |
78 pdf.SetFont('Arial', '', 10) | |
79 pdf.Write(5, "should be working") | |
80 %> | |
81 <%= pdf.Output() %> | |
82 | |
83 | |
84 == Configuring | |
85 | 38 |
86 You can configure Rfpdf by using an @options_for_rfpdf hash in your controllers. | 39 pdf = FPDF.new |
87 | 40 |
88 Here are a few options: | 41 to: |
89 | 42 |
90 :filename (default: action_name.pdf) | 43 pdf = TCPDF.new |
91 Filename of PDF to generate | |
92 | 44 |
93 Note: If you're using the same settings for @options_for_rfpdf often, you might want to | 45 ENJOY! |
94 put your assignment in a before_filter (perhaps overriding :filename, etc in your actions). | |
95 | |
96 == Problems | |
97 | |
98 Layouts and partials are currently not supported; just need | |
99 to wrap the PDF generation differently. |