hpdf 2.0.8-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/History +57 -0
- data/License +25 -0
- data/README +136 -0
- data/docs/annotation_handling.html +503 -0
- data/docs/api.css +115 -0
- data/docs/api_reference.html +112 -0
- data/docs/bindings.html +242 -0
- data/docs/compile_your_program.html +365 -0
- data/docs/default.css +115 -0
- data/docs/destination_handling.html +620 -0
- data/docs/document_handling.html +4751 -0
- data/docs/documentation.html +110 -0
- data/docs/encoder_handling.html +428 -0
- data/docs/error_handling.html +1609 -0
- data/docs/examples.html +702 -0
- data/docs/ext_gstate.html +407 -0
- data/docs/font_handling.html +669 -0
- data/docs/fonts.html +978 -0
- data/docs/graphics.html +1210 -0
- data/docs/handles.html +204 -0
- data/docs/how_to_use.html +371 -0
- data/docs/image/Thumbs.db +0 -0
- data/docs/image/character_map.png +0 -0
- data/docs/image/encoding_list.png +0 -0
- data/docs/image/extgtate.png +0 -0
- data/docs/image/figure1.png +0 -0
- data/docs/image/figure10.png +0 -0
- data/docs/image/figure11.png +0 -0
- data/docs/image/figure12.png +0 -0
- data/docs/image/figure13.png +0 -0
- data/docs/image/figure14.png +0 -0
- data/docs/image/figure15.png +0 -0
- data/docs/image/figure16.png +0 -0
- data/docs/image/figure17.png +0 -0
- data/docs/image/figure18.png +0 -0
- data/docs/image/figure19.png +0 -0
- data/docs/image/figure2.png +0 -0
- data/docs/image/figure20.png +0 -0
- data/docs/image/figure21.png +0 -0
- data/docs/image/figure22.png +0 -0
- data/docs/image/figure23.png +0 -0
- data/docs/image/figure24.png +0 -0
- data/docs/image/figure25.png +0 -0
- data/docs/image/figure26.png +0 -0
- data/docs/image/figure27.png +0 -0
- data/docs/image/figure28.png +0 -0
- data/docs/image/figure3.png +0 -0
- data/docs/image/figure4.png +0 -0
- data/docs/image/figure5.png +0 -0
- data/docs/image/figure6.png +0 -0
- data/docs/image/figure7.png +0 -0
- data/docs/image/figure8.png +0 -0
- data/docs/image/figure9.png +0 -0
- data/docs/image/font_demo.png +0 -0
- data/docs/image/harulogo.png +0 -0
- data/docs/image/image_demo.png +0 -0
- data/docs/image/jpfont_demo.png +0 -0
- data/docs/image/line_demo.png +0 -0
- data/docs/image/png_demo.png +0 -0
- data/docs/image/text_annot.png +0 -0
- data/docs/image/text_demo.png +0 -0
- data/docs/image/text_demo2.png +0 -0
- data/docs/image/tt_font.png +0 -0
- data/docs/image_handling.html +505 -0
- data/docs/index.html +305 -0
- data/docs/install.html +243 -0
- data/docs/outline_handling.html +229 -0
- data/docs/page_handling.html +2647 -0
- data/docs/page_operator.html +2640 -0
- data/docs/useful_links.html +203 -0
- data/examples/arc_demo.rb +82 -0
- data/examples/demo.rb +91 -0
- data/examples/encryption.rb +41 -0
- data/examples/ext_gstater_demo.rb +171 -0
- data/examples/font_demo.rb +67 -0
- data/examples/jpfont_demo.rb +122 -0
- data/examples/line_demo.rb +301 -0
- data/examples/slide_show_demo.rb +139 -0
- data/examples/text_demo2.rb +189 -0
- data/examples/ttfont_demo.rb +106 -0
- data/lib/hpdf.so +0 -0
- data/tests/arc_demo.rb +82 -0
- data/tests/demo.rb +91 -0
- data/tests/encryption.rb +41 -0
- data/tests/ext_gstater_demo.rb +171 -0
- data/tests/font_demo.rb +67 -0
- data/tests/line_demo.rb +301 -0
- data/tests/slide_show_demo.rb +139 -0
- data/tests/test_all_examples.rb +31 -0
- data/tests/text_demo2.rb +189 -0
- metadata +137 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<title>Haru Free PDF Library</title>
|
5
|
+
<meta http-equiv="Content-Type"
|
6
|
+
content="text/html; charset=iso-8859-1">
|
7
|
+
<link href="api.css" type="text/css" rel="stylesheet">
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="headcontainer">
|
11
|
+
<div class="head"><img alt="Haru Free PDF Library"
|
12
|
+
src="image/harulogo.png" style="width: 413px; height: 40px;"></div>
|
13
|
+
</div>
|
14
|
+
<div id="barcontainer">
|
15
|
+
<div class="buildbar"><a href="index.html">home</a> | <a
|
16
|
+
href="http://sourceforge.net/project/showfiles.php?group_id=83044">download</a>
|
17
|
+
|
|
18
|
+
<a href="documentation.html">documentation</a> | <a
|
19
|
+
href="examples.html">examples </a>| <a
|
20
|
+
href="http://sourceforge.net/projects/libharu/">sourceforge</a> |
|
21
|
+
<a href="http://sourceforge.net/forum/?group_id=83044">forums</a><br>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<div id="container">
|
25
|
+
<div id="mainpage">
|
26
|
+
<div id="ccol">
|
27
|
+
<h2>Useful Links<br>
|
28
|
+
</h2>
|
29
|
+
<h3><a name="Programin_Resources"></a>Programin Resources</h3>
|
30
|
+
<div class="bodytext1">
|
31
|
+
<h4>PDF Reference (Adobe Systems Inc.)<br>
|
32
|
+
</h4>
|
33
|
+
URL: <a
|
34
|
+
href="http://partners.adobe.com/public/developer/pdf/index_reference.html">http://partners.adobe.com/public/developer/pdf/index_reference.html</a><br>
|
35
|
+
<br>
|
36
|
+
<h4>Font technical notes (Adobe Systems Inc.)<br>
|
37
|
+
</h4>
|
38
|
+
URL: <a
|
39
|
+
href="http://partners.adobe.com/public/developer/font/index.html">http://partners.adobe.com/public/developer/font/index.html</a><br>
|
40
|
+
<br>
|
41
|
+
<h4>Character Sets and Encodings (Adobe Systems Inc.)</h4>
|
42
|
+
URL: <a
|
43
|
+
href="http://partners.adobe.com/public/developer/opentype/index_char_sets.html">http://partners.adobe.com/public/developer/opentype/index_char_sets.html</a><br>
|
44
|
+
<br>
|
45
|
+
<h4>True Type Font Format (Microsoft Corporation)</h4>
|
46
|
+
URL: <a href="http://www.microsoft.com/typography/otspec/">http://www.microsoft.com/typography/otspec/</a><br>
|
47
|
+
<br>
|
48
|
+
<h4>Unicode Character Database (Unicode Home Page)<br>
|
49
|
+
</h4>
|
50
|
+
URL: <a href="http://www.unicode.org/ucd/">http://www.unicode.org/ucd/</a><br>
|
51
|
+
<br>
|
52
|
+
<h4>The Programmer's File Format Collection<br>
|
53
|
+
</h4>
|
54
|
+
URL: <a href="http://www.wotsit.org/">http://www.wotsit.org/</a><br>
|
55
|
+
<br>
|
56
|
+
<h4>zlib Home Site<br>
|
57
|
+
</h4>
|
58
|
+
URL: <a href="http://www.zlib.net/">http://www.zlib.net/</a><br>
|
59
|
+
<br>
|
60
|
+
<h4>libpng.org<br>
|
61
|
+
</h4>
|
62
|
+
URL: <a href="http://www.libpng.org/">http://www.libpng.org/</a><br>
|
63
|
+
<br>
|
64
|
+
<h4>True Type Font to Postscript Type 1 Converter</h4>
|
65
|
+
URL: <a href="http://ttf2pt1.sourceforge.net/">http://ttf2pt1.sourceforge.net/</a><br>
|
66
|
+
<br>
|
67
|
+
<br>
|
68
|
+
</div>
|
69
|
+
<h3><a name="Font_Resources_"></a>Font Resources<br>
|
70
|
+
</h3>
|
71
|
+
<div class="bodytext1">
|
72
|
+
<h4>Cheapskatefonts.com ("Penguin Attack" font written by Dustin
|
73
|
+
Norlander)<br>
|
74
|
+
</h4>
|
75
|
+
URL: <a href="http://www.dustismo.com/">http://www.dustismo.com/</a><br>
|
76
|
+
<br>
|
77
|
+
<h4>"Konatu" Font (Japanese TrueType font) written by mitiya masuda.<br>
|
78
|
+
</h4>
|
79
|
+
URL: <a href="http://www.masuseki.com/index.php?u=be/">http://www.masuseki.com/index.php?u=be/</a><br>
|
80
|
+
<br>
|
81
|
+
<h4>Ghostscript 6.0 fonts</h4>
|
82
|
+
URL: <a href="http://sourceforge.net/projects/gs-fonts/">http://sourceforge.net/projects/gs-fonts/</a><br>
|
83
|
+
<br>
|
84
|
+
<h4>Type1 KOI8-R font set</h4>
|
85
|
+
URL: <a href="ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts/">ftp://ftp.kapella.gpi.ru/pub/cyrillic/psfonts/</a><br>
|
86
|
+
<br>
|
87
|
+
<h4>CM-Super font package<br>
|
88
|
+
</h4>
|
89
|
+
URL: <a href="http://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/">http://www.ctan.org/tex-archive/fonts/ps-type1/cm-super/</a><br>
|
90
|
+
<br>
|
91
|
+
<h4>Caslon style, ISO 8859 series fonts<br>
|
92
|
+
</h4>
|
93
|
+
URL: <a href="http://bibliofile.mc.duke.edu/gww/fonts/ISO8859.html">http://bibliofile.mc.duke.edu/gww/fonts/ISO8859.html</a><br>
|
94
|
+
</div>
|
95
|
+
<br>
|
96
|
+
<br>
|
97
|
+
<br>
|
98
|
+
<br>
|
99
|
+
<br>
|
100
|
+
<br>
|
101
|
+
<br>
|
102
|
+
<br>
|
103
|
+
<br>
|
104
|
+
<br>
|
105
|
+
<br>
|
106
|
+
<br>
|
107
|
+
<br>
|
108
|
+
<br>
|
109
|
+
<br>
|
110
|
+
<br>
|
111
|
+
<br>
|
112
|
+
<br>
|
113
|
+
<br>
|
114
|
+
<br>
|
115
|
+
<br>
|
116
|
+
<br>
|
117
|
+
<br>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
<div id="lcol">
|
121
|
+
<div class="sidebar">
|
122
|
+
<ul>
|
123
|
+
</ul>
|
124
|
+
<ul>
|
125
|
+
<li><a href="#Programin_Resources">Programing Resources</a></li>
|
126
|
+
<li><a href="#Font_Resources_">Font Resources</a></li>
|
127
|
+
</ul>
|
128
|
+
<br>
|
129
|
+
<br>
|
130
|
+
<br>
|
131
|
+
<br>
|
132
|
+
<br>
|
133
|
+
<br>
|
134
|
+
<br>
|
135
|
+
<br>
|
136
|
+
<br>
|
137
|
+
<br>
|
138
|
+
<br>
|
139
|
+
<br>
|
140
|
+
<br>
|
141
|
+
<br>
|
142
|
+
<br>
|
143
|
+
<br>
|
144
|
+
<br>
|
145
|
+
<br>
|
146
|
+
<br>
|
147
|
+
<br>
|
148
|
+
<br>
|
149
|
+
<br>
|
150
|
+
<br>
|
151
|
+
<br>
|
152
|
+
<br>
|
153
|
+
<br>
|
154
|
+
<br>
|
155
|
+
<br>
|
156
|
+
<br>
|
157
|
+
<br>
|
158
|
+
<br>
|
159
|
+
<br>
|
160
|
+
<br>
|
161
|
+
<br>
|
162
|
+
<br>
|
163
|
+
<br>
|
164
|
+
<br>
|
165
|
+
<br>
|
166
|
+
<br>
|
167
|
+
<br>
|
168
|
+
<br>
|
169
|
+
<br>
|
170
|
+
<br>
|
171
|
+
<br>
|
172
|
+
<br>
|
173
|
+
<br>
|
174
|
+
<br>
|
175
|
+
<br>
|
176
|
+
<br>
|
177
|
+
<br>
|
178
|
+
<br>
|
179
|
+
<br>
|
180
|
+
<br>
|
181
|
+
<br>
|
182
|
+
<br>
|
183
|
+
<br>
|
184
|
+
<br>
|
185
|
+
<br>
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
<br>
|
189
|
+
<br>
|
190
|
+
<br>
|
191
|
+
<br>
|
192
|
+
<br>
|
193
|
+
<br>
|
194
|
+
<br>
|
195
|
+
<br>
|
196
|
+
<br>
|
197
|
+
<br>
|
198
|
+
<br>
|
199
|
+
<br>
|
200
|
+
<br>
|
201
|
+
</div>
|
202
|
+
</body>
|
203
|
+
</html>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb
|
3
|
+
#
|
4
|
+
# http://libharu.sourceforge.net/
|
5
|
+
#
|
6
|
+
# Copyright (c) 1999-2006 Takeshi Kanno
|
7
|
+
#
|
8
|
+
# Permission to use, copy, modify, distribute and sell this software
|
9
|
+
# and its documentation for any purpose is hereby granted without fee,
|
10
|
+
# provided that the above copyright notice appear in all copies and
|
11
|
+
# that both that copyright notice and this permission notice appear
|
12
|
+
# in supporting documentation.
|
13
|
+
# It is provided "as is" without express or implied warranty.
|
14
|
+
#
|
15
|
+
|
16
|
+
require "hpdf"
|
17
|
+
|
18
|
+
pdf = HPDFDoc.new
|
19
|
+
|
20
|
+
# add a new page object. #
|
21
|
+
page = pdf.add_page
|
22
|
+
|
23
|
+
page.set_height(220)
|
24
|
+
page.set_width(200)
|
25
|
+
|
26
|
+
# draw pie chart
|
27
|
+
#
|
28
|
+
# A: 45% Red
|
29
|
+
# B: 25% Blue
|
30
|
+
# C: 15% green
|
31
|
+
# D: other yellow
|
32
|
+
#
|
33
|
+
|
34
|
+
# A #
|
35
|
+
page.set_rgb_fill(1.0, 0, 0)
|
36
|
+
page.move_to(100, 100)
|
37
|
+
page.line_to(100, 180)
|
38
|
+
page.arc(100, 100, 80, 0, 360 * 0.45)
|
39
|
+
pos = page.get_current_pos
|
40
|
+
page.line_to(100, 100)
|
41
|
+
page.fill
|
42
|
+
|
43
|
+
# B #
|
44
|
+
page.set_rgb_fill(0, 0, 1.0)
|
45
|
+
page.move_to(100, 100)
|
46
|
+
page.line_to(pos[0], pos[1])
|
47
|
+
page.arc(100, 100, 80, 360 * 0.45, 360 * 0.7)
|
48
|
+
pos = page.get_current_pos
|
49
|
+
page.line_to(100, 100)
|
50
|
+
page.fill
|
51
|
+
|
52
|
+
# C #
|
53
|
+
page.set_rgb_fill(0, 1.0, 0)
|
54
|
+
page.move_to(100, 100)
|
55
|
+
page.line_to(pos[0], pos[1])
|
56
|
+
page.arc(100, 100, 80, 360 * 0.7, 360 * 0.85)
|
57
|
+
pos = page.get_current_pos
|
58
|
+
page.line_to(100, 100)
|
59
|
+
page.fill
|
60
|
+
|
61
|
+
# D #
|
62
|
+
page.set_rgb_fill(1.0, 1.0, 0)
|
63
|
+
page.move_to(100, 100)
|
64
|
+
page.line_to(pos[0], pos[1])
|
65
|
+
page.arc(100, 100, 80, 360 * 0.85, 360)
|
66
|
+
pos = page.get_current_pos
|
67
|
+
page.line_to(100, 100)
|
68
|
+
page.fill
|
69
|
+
|
70
|
+
# draw center circle #
|
71
|
+
page.set_gray_stroke(0)
|
72
|
+
page.set_gray_fill(1)
|
73
|
+
page.circle(100, 100, 30)
|
74
|
+
page.fill
|
75
|
+
|
76
|
+
if $demo_output_filename
|
77
|
+
file_name= $demo_output_filename
|
78
|
+
else
|
79
|
+
file_name= $0 + ".pdf"
|
80
|
+
end
|
81
|
+
|
82
|
+
pdf.save_to_file(file_name)
|
data/examples/demo.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.0 >> -- demo.rb
|
3
|
+
#
|
4
|
+
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
|
5
|
+
#
|
6
|
+
# Permission to use, copy, modify, distribute and sell this software
|
7
|
+
# and its documentation for any purpose is hereby granted without fee,
|
8
|
+
# provided that the above copyright notice appear in all copies and
|
9
|
+
# that both that copyright notice and this permission notice appear
|
10
|
+
# in supporting documentation.
|
11
|
+
# It is provided "as is" without express or implied warranty.
|
12
|
+
#
|
13
|
+
|
14
|
+
require "hpdf"
|
15
|
+
|
16
|
+
if ARGV.empty?
|
17
|
+
line = 'Ruby Rocks'
|
18
|
+
else
|
19
|
+
line = ARGV.join(" ")
|
20
|
+
end
|
21
|
+
|
22
|
+
pdf = HPDFDoc.new
|
23
|
+
|
24
|
+
page = pdf.add_page
|
25
|
+
|
26
|
+
x = 578
|
27
|
+
r1 = 25
|
28
|
+
|
29
|
+
40.step(1, -3) do |xw|
|
30
|
+
tone = 1.0 - (xw / 40.0) * 0.2
|
31
|
+
|
32
|
+
page.set_line_width(xw.to_f)
|
33
|
+
page.set_rgb_stroke(tone, 1.0, tone)
|
34
|
+
page.circle(50.0, 750.0, r1.to_f)
|
35
|
+
page.stroke
|
36
|
+
r1 += xw
|
37
|
+
end
|
38
|
+
|
39
|
+
40.step(1, -3) do |xw|
|
40
|
+
tone = 1.0 - (xw / 40.0) * 0.2
|
41
|
+
|
42
|
+
page.set_line_width(xw.to_f)
|
43
|
+
page.set_rgb_stroke(tone, tone, 1.0)
|
44
|
+
page.move_to(x.to_f, 0.0)
|
45
|
+
page.line_to(x.to_f, 842.0)
|
46
|
+
page.stroke
|
47
|
+
x = (x - xw - 2)
|
48
|
+
end
|
49
|
+
|
50
|
+
page.set_rgb_stroke(0.0, 0.0, 0.0)
|
51
|
+
page.set_line_width(1.0)
|
52
|
+
page.rectangle(20.0, 20.0, 558.0, 802.0)
|
53
|
+
page.stroke
|
54
|
+
|
55
|
+
font = pdf.get_font("Helvetica", nil)
|
56
|
+
bbox = font.get_bbox
|
57
|
+
|
58
|
+
y = 800
|
59
|
+
50.step(5, -5) do |size|
|
60
|
+
height = (bbox[3] - bbox[1]) / 1000 * size
|
61
|
+
y = y - height
|
62
|
+
|
63
|
+
page.begin_text
|
64
|
+
page.set_font_and_size(font, size.to_f)
|
65
|
+
page.text_out(30.0, y.to_f, line)
|
66
|
+
page.end_text
|
67
|
+
end
|
68
|
+
|
69
|
+
(0...360).step(20) do |angle|
|
70
|
+
page.set_rgb_fill(rand, rand, rand)
|
71
|
+
|
72
|
+
page.begin_text
|
73
|
+
rad = angle / 180.0 * 3.141592
|
74
|
+
page.set_font_and_size(font, 20.0)
|
75
|
+
page.set_text_matrix(Math.cos(rad),
|
76
|
+
Math.sin(rad),
|
77
|
+
-Math.sin(rad),
|
78
|
+
Math.cos(rad),
|
79
|
+
300 + Math.cos(rad) * 40,
|
80
|
+
300 + Math.sin(rad) * 40)
|
81
|
+
page.show_text(line)
|
82
|
+
page.end_text
|
83
|
+
end
|
84
|
+
|
85
|
+
if $demo_output_filename
|
86
|
+
file_name= $demo_output_filename
|
87
|
+
else
|
88
|
+
file_name= $0 + ".pdf"
|
89
|
+
end
|
90
|
+
|
91
|
+
pdf.save_to_file(file_name)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.0 >> -- encryption.rb
|
3
|
+
#
|
4
|
+
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
|
5
|
+
#
|
6
|
+
# Permission to use, copy, modify, distribute and sell this software
|
7
|
+
# and its documentation for any purpose is hereby granted without fee,
|
8
|
+
# provided that the above copyright notice appear in all copies and
|
9
|
+
# that both that copyright notice and this permission notice appear
|
10
|
+
# in supporting documentation.
|
11
|
+
# It is provided "as is" without express or implied warranty.
|
12
|
+
#
|
13
|
+
|
14
|
+
require "hpdf"
|
15
|
+
|
16
|
+
pdf = HPDFDoc.new
|
17
|
+
|
18
|
+
text = "This is an encrypt document example."
|
19
|
+
owner_passwd = "owner"
|
20
|
+
user_passwd = "user"
|
21
|
+
|
22
|
+
font1 = pdf.get_font("Helvetica", nil)
|
23
|
+
|
24
|
+
page = pdf.add_page
|
25
|
+
|
26
|
+
page.set_size(HPDFDoc::HPDF_PAGE_SIZE_B5, HPDFDoc::HPDF_PAGE_LANDSCAPE)
|
27
|
+
|
28
|
+
page.begin_text
|
29
|
+
page.set_font_and_size(font1, 20)
|
30
|
+
page.text_rect(0, page.get_height / 2 + 20, page.get_width, page.get_height / 2 -10, text, HPDFDoc::HPDF_TALIGN_CENTER)
|
31
|
+
page.end_text
|
32
|
+
|
33
|
+
pdf.set_password(owner_passwd, user_passwd)
|
34
|
+
|
35
|
+
if $demo_output_filename
|
36
|
+
file_name= $demo_output_filename
|
37
|
+
else
|
38
|
+
file_name= $0 + ".pdf"
|
39
|
+
end
|
40
|
+
|
41
|
+
pdf.save_to_file(file_name)
|
@@ -0,0 +1,171 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb
|
3
|
+
#
|
4
|
+
# http://libharu.sourceforge.net/
|
5
|
+
#
|
6
|
+
# Copyright (c) 1999-2006 Takeshi Kanno
|
7
|
+
#
|
8
|
+
# Permission to use, copy, modify, distribute and sell this software
|
9
|
+
# and its documentation for any purpose is hereby granted without fee,
|
10
|
+
# provided that the above copyright notice appear in all copies and
|
11
|
+
# that both that copyright notice and this permission notice appear
|
12
|
+
# in supporting documentation.
|
13
|
+
# It is provided "as is" without express or implied warranty.
|
14
|
+
#
|
15
|
+
|
16
|
+
require "hpdf"
|
17
|
+
|
18
|
+
def draw_circles(page, description, x, y)
|
19
|
+
page.set_line_width(1)
|
20
|
+
page.set_rgb_stroke(0, 0, 0)
|
21
|
+
|
22
|
+
page.set_rgb_fill(1, 0, 0)
|
23
|
+
page.circle(x + 40, y + 40, 40)
|
24
|
+
page.close_path_fill_stroke()
|
25
|
+
|
26
|
+
page.set_rgb_fill(0, 1, 0)
|
27
|
+
page.circle(x + 100, y + 40, 40)
|
28
|
+
page.close_path_fill_stroke()
|
29
|
+
|
30
|
+
page.set_rgb_fill(0, 0, 1)
|
31
|
+
page.circle(x + 70, y + 74.64, 40)
|
32
|
+
page.close_path_fill_stroke()
|
33
|
+
|
34
|
+
page.set_rgb_fill(0, 0, 0)
|
35
|
+
page.begin_text()
|
36
|
+
page.text_out(x + 0.0, y + 130.0, description)
|
37
|
+
page.end_text()
|
38
|
+
end
|
39
|
+
|
40
|
+
pdf = HPDFDoc.new
|
41
|
+
|
42
|
+
PAGE_WIDTH = 600
|
43
|
+
PAGE_HEIGHT = 900
|
44
|
+
|
45
|
+
# add a new page object. #
|
46
|
+
page = pdf.add_page
|
47
|
+
page.set_height(PAGE_HEIGHT)
|
48
|
+
page.set_width(PAGE_WIDTH)
|
49
|
+
|
50
|
+
font = pdf.get_font("Helvetica-Bold", nil)
|
51
|
+
|
52
|
+
page.set_font_and_size(font, 10)
|
53
|
+
|
54
|
+
# normal
|
55
|
+
page.gsave()
|
56
|
+
draw_circles(page, "normal", 40, PAGE_HEIGHT - 170)
|
57
|
+
page.grestore()
|
58
|
+
|
59
|
+
# transparency (0.8)
|
60
|
+
page.gsave()
|
61
|
+
gstate = pdf.create_ext_gstate()
|
62
|
+
gstate.set_alpha_fill(0.8)
|
63
|
+
gstate.set_alpha_stroke(0.8)
|
64
|
+
page.set_ext_gstate(gstate)
|
65
|
+
draw_circles(page, "alpha fill = 0.8", 230, PAGE_HEIGHT - 170)
|
66
|
+
page.grestore()
|
67
|
+
|
68
|
+
# transparency (0.4)
|
69
|
+
page.gsave()
|
70
|
+
gstate = pdf.create_ext_gstate()
|
71
|
+
gstate.set_alpha_fill(0.4)
|
72
|
+
gstate.set_alpha_stroke(0.4)
|
73
|
+
page.set_ext_gstate(gstate)
|
74
|
+
draw_circles(page, "alpha fill = 0.4", 420, PAGE_HEIGHT - 170)
|
75
|
+
page.grestore()
|
76
|
+
|
77
|
+
# blend-mode=HPDF_BM_MULTIPLY
|
78
|
+
page.gsave()
|
79
|
+
gstate = pdf.create_ext_gstate()
|
80
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_MULTIPLY)
|
81
|
+
page.set_ext_gstate(gstate)
|
82
|
+
draw_circles(page, "HPDF_BM_MULTIPLY", 40, PAGE_HEIGHT - 340)
|
83
|
+
page.grestore()
|
84
|
+
|
85
|
+
# blend-mode=HPDF_BM_SCREEN
|
86
|
+
page.gsave()
|
87
|
+
gstate = pdf.create_ext_gstate()
|
88
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_SCREEN)
|
89
|
+
page.set_ext_gstate(gstate)
|
90
|
+
draw_circles(page, "HPDF_BM_SCREEN", 230, PAGE_HEIGHT - 340)
|
91
|
+
page.grestore()
|
92
|
+
|
93
|
+
# blend-mode=HPDF_BM_OVERLAY
|
94
|
+
page.gsave()
|
95
|
+
gstate = pdf.create_ext_gstate()
|
96
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_OVERLAY)
|
97
|
+
page.set_ext_gstate(gstate)
|
98
|
+
draw_circles(page, "HPDF_BM_OVERLAY", 420, PAGE_HEIGHT - 340)
|
99
|
+
page.grestore()
|
100
|
+
|
101
|
+
# blend-mode=HPDF_BM_DARKEN
|
102
|
+
page.gsave()
|
103
|
+
gstate = pdf.create_ext_gstate()
|
104
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_DARKEN)
|
105
|
+
page.set_ext_gstate(gstate)
|
106
|
+
draw_circles(page, "HPDF_BM_DARKEN", 40, PAGE_HEIGHT - 510)
|
107
|
+
page.grestore()
|
108
|
+
|
109
|
+
# blend-mode=HPDF_BM_LIGHTEN
|
110
|
+
page.gsave()
|
111
|
+
gstate = pdf.create_ext_gstate()
|
112
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_LIGHTEN)
|
113
|
+
page.set_ext_gstate(gstate)
|
114
|
+
draw_circles(page, "HPDF_BM_LIGHTEN", 230, PAGE_HEIGHT - 510)
|
115
|
+
page.grestore()
|
116
|
+
|
117
|
+
# blend-mode=HPDF_BM_COLOR_DODGE
|
118
|
+
page.gsave()
|
119
|
+
gstate = pdf.create_ext_gstate()
|
120
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_COLOR_DODGE)
|
121
|
+
page.set_ext_gstate(gstate)
|
122
|
+
draw_circles(page, "HPDF_BM_COLOR_DODGE", 420, PAGE_HEIGHT - 510)
|
123
|
+
page.grestore()
|
124
|
+
|
125
|
+
# blend-mode=HPDF_BM_COLOR_BUM
|
126
|
+
page.gsave()
|
127
|
+
gstate = pdf.create_ext_gstate()
|
128
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_COLOR_BUM)
|
129
|
+
page.set_ext_gstate(gstate)
|
130
|
+
draw_circles(page, "HPDF_BM_COLOR_BUM", 40, PAGE_HEIGHT - 680)
|
131
|
+
page.grestore()
|
132
|
+
|
133
|
+
# blend-mode=HPDF_BM_HARD_LIGHT
|
134
|
+
page.gsave()
|
135
|
+
gstate = pdf.create_ext_gstate()
|
136
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_HARD_LIGHT)
|
137
|
+
page.set_ext_gstate(gstate)
|
138
|
+
draw_circles(page, "HPDF_BM_HARD_LIGHT", 230, PAGE_HEIGHT - 680)
|
139
|
+
page.grestore()
|
140
|
+
|
141
|
+
# blend-mode=HPDF_BM_SOFT_LIGHT
|
142
|
+
page.gsave()
|
143
|
+
gstate = pdf.create_ext_gstate()
|
144
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_SOFT_LIGHT)
|
145
|
+
page.set_ext_gstate(gstate)
|
146
|
+
draw_circles(page, "HPDF_BM_SOFT_LIGHT", 420, PAGE_HEIGHT - 680)
|
147
|
+
page.grestore()
|
148
|
+
|
149
|
+
# blend-mode=HPDF_BM_DIFFERENCE
|
150
|
+
page.gsave()
|
151
|
+
gstate = pdf.create_ext_gstate()
|
152
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_DIFFERENCE)
|
153
|
+
page.set_ext_gstate(gstate)
|
154
|
+
draw_circles(page, "HPDF_BM_DIFFERENCE", 40, PAGE_HEIGHT - 850)
|
155
|
+
page.grestore()
|
156
|
+
|
157
|
+
# blend-mode=HPDF_BM_EXCLUSHON
|
158
|
+
page.gsave()
|
159
|
+
gstate = pdf.create_ext_gstate()
|
160
|
+
gstate.set_blend_mode(HPDFDoc::HPDF_BM_EXCLUSHON)
|
161
|
+
page.set_ext_gstate(gstate)
|
162
|
+
draw_circles(page, "HPDF_BM_EXCLUSHON", 230, PAGE_HEIGHT - 850)
|
163
|
+
page.grestore()
|
164
|
+
|
165
|
+
if $demo_output_filename
|
166
|
+
file_name= $demo_output_filename
|
167
|
+
else
|
168
|
+
file_name= $0 + ".pdf"
|
169
|
+
end
|
170
|
+
|
171
|
+
pdf.save_to_file(file_name)
|