hpdf 2.0.8-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,139 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.6 >> -- slideshow_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
|
+
RAND_MAX = 255
|
19
|
+
|
20
|
+
def print_page(page, caption, font, style, prev, next_p)
|
21
|
+
|
22
|
+
r = rand
|
23
|
+
g = rand
|
24
|
+
b = rand
|
25
|
+
|
26
|
+
page.set_width(800)
|
27
|
+
page.set_height(600)
|
28
|
+
|
29
|
+
page.set_rgb_fill(r, g, b)
|
30
|
+
page.rectangle(0, 0, 800, 600)
|
31
|
+
page.fill()
|
32
|
+
|
33
|
+
page.set_rgb_fill(1 - r, 1 - b, 1 - b)
|
34
|
+
page.set_font_and_size(font, 30)
|
35
|
+
|
36
|
+
page.begin_text()
|
37
|
+
page.set_text_matrix(0.8, 0.0, 0.0, 1.0, 0.0, 0.0);
|
38
|
+
page.text_out(50, 530, caption)
|
39
|
+
|
40
|
+
page.set_text_matrix(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
|
41
|
+
page.set_font_and_size(font, 20)
|
42
|
+
page.text_out(55, 300, "Type \"Ctrl+L\" in order to return from full screen mode.")
|
43
|
+
page.end_text()
|
44
|
+
|
45
|
+
page.set_slide_show(style, 5, 1)
|
46
|
+
page.set_font_and_size(font, 20)
|
47
|
+
|
48
|
+
if (next_p != nil)
|
49
|
+
page.begin_text()
|
50
|
+
page.text_out(680, 50, "Next=>")
|
51
|
+
page.end_text()
|
52
|
+
|
53
|
+
dst = next_p.create_destination()
|
54
|
+
dst.set_fit()
|
55
|
+
annot = page.create_link_annot(680, 50, 680, 70, dst)
|
56
|
+
annot.set_border_style(0, 0, 0)
|
57
|
+
annot.set_highlight_mode(HPDFDoc::HPDF_ANNOT_INVERT_BOX)
|
58
|
+
end
|
59
|
+
|
60
|
+
if (prev != nil)
|
61
|
+
page.begin_text()
|
62
|
+
page.text_out(50, 50, "<=Prev")
|
63
|
+
page.end_text()
|
64
|
+
|
65
|
+
dst = prev.create_destination()
|
66
|
+
dst.set_fit()
|
67
|
+
annot = page.create_link_annot(50, 50, 110, 70, dst)
|
68
|
+
annot.set_border_style(0, 0, 0)
|
69
|
+
annot.set_highlight_mode(HPDFDoc::HPDF_ANNOT_INVERT_BOX)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
pdf = HPDFDoc.new
|
76
|
+
|
77
|
+
font = pdf.get_font("Courier", nil)
|
78
|
+
page_0 = pdf.add_page()
|
79
|
+
page_1 = pdf.add_page()
|
80
|
+
page_2 = pdf.add_page()
|
81
|
+
page_3 = pdf.add_page()
|
82
|
+
page_4 = pdf.add_page()
|
83
|
+
page_5 = pdf.add_page()
|
84
|
+
page_6 = pdf.add_page()
|
85
|
+
page_7 = pdf.add_page()
|
86
|
+
page_8 = pdf.add_page()
|
87
|
+
page_9 = pdf.add_page()
|
88
|
+
page_10 = pdf.add_page()
|
89
|
+
page_11 = pdf.add_page()
|
90
|
+
page_12 = pdf.add_page()
|
91
|
+
page_13 = pdf.add_page()
|
92
|
+
page_14 = pdf.add_page()
|
93
|
+
page_15 = pdf.add_page()
|
94
|
+
page_16 = pdf.add_page()
|
95
|
+
|
96
|
+
print_page(page_0, "HPDFDoc::HPDF_TS_WIPE_RIGHT", font,
|
97
|
+
HPDFDoc::HPDF_TS_WIPE_RIGHT, nil, page_1);
|
98
|
+
print_page(page_1, "HPDFDoc::HPDF_TS_WIPE_UP", font,
|
99
|
+
HPDFDoc::HPDF_TS_WIPE_UP, page_0, page_2);
|
100
|
+
print_page(page_2, "HPDFDoc::HPDF_TS_WIPE_LEFT", font,
|
101
|
+
HPDFDoc::HPDF_TS_WIPE_LEFT, page_1, page_3);
|
102
|
+
print_page(page_3, "HPDFDoc::HPDF_TS_WIPE_DOWN", font,
|
103
|
+
HPDFDoc::HPDF_TS_WIPE_DOWN, page_2, page_4);
|
104
|
+
print_page(page_4, "HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_OUT", font,
|
105
|
+
HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_OUT, page_3, page_5);
|
106
|
+
print_page(page_5, "HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_IN", font,
|
107
|
+
HPDFDoc::HPDF_TS_BARN_DOORS_HORIZONTAL_IN, page_4, page_6);
|
108
|
+
print_page(page_6, "HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_OUT", font,
|
109
|
+
HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_OUT, page_5, page_7);
|
110
|
+
print_page(page_7, "HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_IN", font,
|
111
|
+
HPDFDoc::HPDF_TS_BARN_DOORS_VERTICAL_IN, page_6, page_8);
|
112
|
+
print_page(page_8, "HPDFDoc::HPDF_TS_BOX_OUT", font,
|
113
|
+
HPDFDoc::HPDF_TS_BOX_OUT, page_7, page_9);
|
114
|
+
print_page(page_9, "HPDFDoc::HPDF_TS_BOX_IN", font,
|
115
|
+
HPDFDoc::HPDF_TS_BOX_IN, page_8, page_10);
|
116
|
+
print_page(page_10, "HPDFDoc::HPDF_TS_BLINDS_HORIZONTAL", font,
|
117
|
+
HPDFDoc::HPDF_TS_BLINDS_HORIZONTAL, page_9, page_11);
|
118
|
+
print_page(page_11, "HPDFDoc::HPDF_TS_BLINDS_VERTICAL", font,
|
119
|
+
HPDFDoc::HPDF_TS_BLINDS_VERTICAL, page_10, page_12);
|
120
|
+
print_page(page_12, "HPDFDoc::HPDF_TS_DISSOLVE", font,
|
121
|
+
HPDFDoc::HPDF_TS_DISSOLVE, page_11, page_13);
|
122
|
+
print_page(page_13, "HPDFDoc::HPDF_TS_GLITTER_RIGHT", font,
|
123
|
+
HPDFDoc::HPDF_TS_GLITTER_RIGHT, page_12, page_14);
|
124
|
+
print_page(page_14, "HPDFDoc::HPDF_TS_GLITTER_DOWN", font,
|
125
|
+
HPDFDoc::HPDF_TS_GLITTER_DOWN, page_13, page_15);
|
126
|
+
print_page(page_15, "HPDFDoc::HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT", font,
|
127
|
+
HPDFDoc::HPDF_TS_GLITTER_TOP_LEFT_TO_BOTTOM_RIGHT, page_14, page_16);
|
128
|
+
print_page(page_16, "HPDFDoc::HPDF_TS_REPLACE", font,
|
129
|
+
HPDFDoc::HPDF_TS_REPLACE, page_15, nil);
|
130
|
+
|
131
|
+
pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_FULL_SCREEN)
|
132
|
+
|
133
|
+
if $demo_output_filename
|
134
|
+
file_name= $demo_output_filename
|
135
|
+
else
|
136
|
+
file_name= $0 + ".pdf"
|
137
|
+
end
|
138
|
+
|
139
|
+
pdf.save_to_file(file_name)
|
@@ -0,0 +1,189 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.0 >> -- text_demo2.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
|
+
samp_text = "The quick brown fox jumps over the lazy dog. "
|
17
|
+
|
18
|
+
pdf = HPDFDoc.new
|
19
|
+
|
20
|
+
page = pdf.add_page
|
21
|
+
page.set_size(HPDFDoc::HPDF_PAGE_SIZE_A5, HPDFDoc::HPDF_PAGE_PORTRAIT)
|
22
|
+
height = page.get_height
|
23
|
+
|
24
|
+
font = pdf.get_font("Helvetica", nil)
|
25
|
+
page.set_text_leading(20)
|
26
|
+
|
27
|
+
# HPDF_TALIGN_LEFT
|
28
|
+
left = 25
|
29
|
+
top = 545
|
30
|
+
right = 200
|
31
|
+
bottom = top - 40
|
32
|
+
|
33
|
+
page.rectangle(left, bottom, right - left, top - bottom)
|
34
|
+
page.stroke
|
35
|
+
|
36
|
+
page.begin_text
|
37
|
+
page.set_font_and_size(font, 10)
|
38
|
+
page.text_out(left, top + 3, "HPDF_TALIGN_LEFT")
|
39
|
+
|
40
|
+
page.set_font_and_size(font, 13)
|
41
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
|
42
|
+
page.end_text
|
43
|
+
|
44
|
+
# HPDF_TALIGN_RIGHT
|
45
|
+
left = 220
|
46
|
+
right = 395
|
47
|
+
|
48
|
+
page.rectangle(left, bottom, right - left, top - bottom)
|
49
|
+
page.stroke
|
50
|
+
|
51
|
+
page.begin_text
|
52
|
+
page.set_font_and_size(font, 10)
|
53
|
+
page.text_out(left, top + 3, "HPDF_TALIGN_RIGHT")
|
54
|
+
|
55
|
+
page.set_font_and_size(font, 13)
|
56
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_RIGHT)
|
57
|
+
page.end_text
|
58
|
+
|
59
|
+
# HPDF_TALIGN_CENTER
|
60
|
+
left = 25
|
61
|
+
top = 475
|
62
|
+
right = 200
|
63
|
+
bottom = top - 40
|
64
|
+
|
65
|
+
page.rectangle(left, bottom, right - left, top - bottom)
|
66
|
+
page.stroke
|
67
|
+
|
68
|
+
page.begin_text
|
69
|
+
page.set_font_and_size(font, 10)
|
70
|
+
page.text_out(left, top + 3, "HPDF_TALIGN_CENTER")
|
71
|
+
|
72
|
+
page.set_font_and_size(font, 13)
|
73
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_CENTER)
|
74
|
+
page.end_text
|
75
|
+
|
76
|
+
# HPDF_TALIGN_JUSTIFY
|
77
|
+
left = 220
|
78
|
+
right = 395
|
79
|
+
|
80
|
+
page.rectangle(left, bottom, right - left, top - bottom)
|
81
|
+
page.stroke
|
82
|
+
|
83
|
+
page.begin_text
|
84
|
+
page.set_font_and_size(font, 10)
|
85
|
+
page.text_out(left, top + 3, "HPDF_TALIGN_JUSTIFY")
|
86
|
+
|
87
|
+
page.set_font_and_size(font, 13)
|
88
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_JUSTIFY)
|
89
|
+
page.end_text
|
90
|
+
|
91
|
+
|
92
|
+
# Skewed coordinate system
|
93
|
+
|
94
|
+
angle1 = 5.0
|
95
|
+
angle2 = 10.0
|
96
|
+
rad1 = angle1 / 180 * 3.141592
|
97
|
+
rad2 = angle2 / 180 * 3.141592
|
98
|
+
|
99
|
+
page.gsave
|
100
|
+
|
101
|
+
page.concat(1, Math.tan(rad1), Math.tan(rad2), 1, 25, 350)
|
102
|
+
left = 0
|
103
|
+
top = 40
|
104
|
+
right = 175
|
105
|
+
bottom = 0
|
106
|
+
|
107
|
+
page.rectangle(left, bottom, right - left,
|
108
|
+
top - bottom)
|
109
|
+
page.stroke
|
110
|
+
|
111
|
+
page.begin_text
|
112
|
+
|
113
|
+
page.set_font_and_size(font, 10)
|
114
|
+
page.text_out(left, top + 3, "Skewed coordinate system")
|
115
|
+
|
116
|
+
page.set_font_and_size(font, 13)
|
117
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
|
118
|
+
|
119
|
+
page.end_text
|
120
|
+
|
121
|
+
page.grestore
|
122
|
+
|
123
|
+
|
124
|
+
# Rotated coordinate system
|
125
|
+
page.gsave
|
126
|
+
|
127
|
+
angle1 = 5.0
|
128
|
+
rad1 = angle1 / 180 * 3.141592
|
129
|
+
|
130
|
+
page.concat(Math.cos(rad1), Math.sin(rad1), -Math.sin(rad1), Math.cos(rad1), 220, 350)
|
131
|
+
left = 0
|
132
|
+
top = 40
|
133
|
+
right = 175
|
134
|
+
bottom = 0
|
135
|
+
|
136
|
+
page.rectangle(left, bottom, right - left,
|
137
|
+
top - bottom)
|
138
|
+
page.stroke
|
139
|
+
|
140
|
+
page.begin_text
|
141
|
+
|
142
|
+
page.set_font_and_size(font, 10)
|
143
|
+
page.text_out(left, top + 3, "Rotated coordinate system")
|
144
|
+
|
145
|
+
page.set_font_and_size(font, 13)
|
146
|
+
page.text_rect(left, top, right, bottom, samp_text, HPDFDoc::HPDF_TALIGN_LEFT)
|
147
|
+
|
148
|
+
page.end_text
|
149
|
+
|
150
|
+
page.grestore
|
151
|
+
|
152
|
+
|
153
|
+
# text along a circle
|
154
|
+
page.set_gray_stroke(0)
|
155
|
+
page.circle(210, 190, 145)
|
156
|
+
page.circle(210, 190, 113)
|
157
|
+
page.stroke
|
158
|
+
|
159
|
+
angle1 = 360.0 / samp_text.length
|
160
|
+
angle2 = 180.0
|
161
|
+
|
162
|
+
page.begin_text
|
163
|
+
font = pdf.get_font("Courier-Bold", nil)
|
164
|
+
page.set_font_and_size(font, 30)
|
165
|
+
|
166
|
+
i = 0
|
167
|
+
while i < samp_text.length
|
168
|
+
rad1 = (angle2 - 90) / 180 * 3.141592
|
169
|
+
rad2 = angle2 / 180 * 3.141592
|
170
|
+
|
171
|
+
x = 210.0 + Math.cos(rad2) * 122
|
172
|
+
y = 190.0 + Math.sin(rad2) * 122
|
173
|
+
|
174
|
+
page.set_text_matrix(Math.cos(rad1), Math.sin(rad1), -Math.sin(rad1), Math.cos(rad1), x, y)
|
175
|
+
|
176
|
+
page.show_text(samp_text[i, 1])
|
177
|
+
angle2 -= angle1
|
178
|
+
i = i + 1
|
179
|
+
end
|
180
|
+
|
181
|
+
page.end_text
|
182
|
+
|
183
|
+
if $demo_output_filename
|
184
|
+
file_name= $demo_output_filename
|
185
|
+
else
|
186
|
+
file_name= $0 + ".pdf"
|
187
|
+
end
|
188
|
+
|
189
|
+
pdf.save_to_file(file_name)
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#
|
2
|
+
# << Haru Free PDF Library 2.0.2 >> -- ttfont_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
|
+
SAMP_TXT = "The quick brown fox jumps over the lazy dog."
|
19
|
+
|
20
|
+
font_name = ARGV.shift
|
21
|
+
flg = ARGV.shift
|
22
|
+
|
23
|
+
if !font_name
|
24
|
+
print 'usage: ttfont_demo.rb [path to font file] -E(embedding font).'
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
pdf = HPDFDoc.new
|
29
|
+
|
30
|
+
pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
|
31
|
+
|
32
|
+
# Add a new page object. #
|
33
|
+
page = pdf.add_page
|
34
|
+
|
35
|
+
title_font = pdf.get_font("Helvetica", nil)
|
36
|
+
|
37
|
+
if (flg == "-E")
|
38
|
+
embed = HPDFDoc::HPDF_TRUE
|
39
|
+
else
|
40
|
+
embed = HPDFDoc::HPDF_FALSE
|
41
|
+
end
|
42
|
+
|
43
|
+
detail_font_name = pdf.load_ttfont_from_file(font_name, embed)
|
44
|
+
print font_name, ' load OK.[', detail_font_name, ']'
|
45
|
+
|
46
|
+
detail_font = pdf.get_font(detail_font_name, nil)
|
47
|
+
|
48
|
+
page.set_font_and_size(title_font, 10)
|
49
|
+
|
50
|
+
page.begin_text
|
51
|
+
|
52
|
+
# Move the position of the text to top of the page. #
|
53
|
+
page.move_text_pos(10, 190)
|
54
|
+
page.show_text(detail_font_name)
|
55
|
+
|
56
|
+
if (embed)
|
57
|
+
page.show_text("(Embedded Subset)")
|
58
|
+
end
|
59
|
+
|
60
|
+
page.set_font_and_size(detail_font, 15)
|
61
|
+
page.move_text_pos(10, -20)
|
62
|
+
page.show_text("abcdefghijklmnopqrstuvwxyz")
|
63
|
+
page.move_text_pos(0, -20)
|
64
|
+
page.show_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
65
|
+
page.move_text_pos(0, -20)
|
66
|
+
page.show_text("1234567890")
|
67
|
+
page.move_text_pos(0, -20)
|
68
|
+
|
69
|
+
page.set_font_and_size(detail_font, 10)
|
70
|
+
page.show_text(SAMP_TXT)
|
71
|
+
page.move_text_pos(0, -18)
|
72
|
+
|
73
|
+
page.set_font_and_size(detail_font, 16)
|
74
|
+
page.show_text(SAMP_TXT)
|
75
|
+
page.move_text_pos(0, -27)
|
76
|
+
|
77
|
+
page.set_font_and_size(detail_font, 23)
|
78
|
+
page.show_text(SAMP_TXT)
|
79
|
+
page.move_text_pos(0, -36)
|
80
|
+
|
81
|
+
page.set_font_and_size(detail_font, 30)
|
82
|
+
page.show_text(SAMP_TXT)
|
83
|
+
page.move_text_pos(0, -36)
|
84
|
+
|
85
|
+
tw = page.text_width(SAMP_TXT)
|
86
|
+
page_height = 210
|
87
|
+
page_width = tw + 40
|
88
|
+
|
89
|
+
page.set_width(page_width)
|
90
|
+
page.set_height(page_height)
|
91
|
+
|
92
|
+
# Finish to print text. #
|
93
|
+
page.end_text
|
94
|
+
|
95
|
+
page.set_line_width(0.5)
|
96
|
+
|
97
|
+
page.move_to(10, page_height - 25)
|
98
|
+
page.line_to(page_width - 10, page_height - 25)
|
99
|
+
page.stroke
|
100
|
+
|
101
|
+
page.move_to(10, page_height - 85)
|
102
|
+
page.line_to(page_width - 10, page_height - 85)
|
103
|
+
page.stroke
|
104
|
+
|
105
|
+
file_name= $0 + ".pdf"
|
106
|
+
pdf.save_to_file(file_name)
|
data/lib/hpdf.so
ADDED
Binary file
|
data/tests/arc_demo.rb
ADDED
@@ -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)
|