hpdf 2.0.8-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/History +57 -0
  2. data/License +25 -0
  3. data/README +136 -0
  4. data/docs/annotation_handling.html +503 -0
  5. data/docs/api.css +115 -0
  6. data/docs/api_reference.html +112 -0
  7. data/docs/bindings.html +242 -0
  8. data/docs/compile_your_program.html +365 -0
  9. data/docs/default.css +115 -0
  10. data/docs/destination_handling.html +620 -0
  11. data/docs/document_handling.html +4751 -0
  12. data/docs/documentation.html +110 -0
  13. data/docs/encoder_handling.html +428 -0
  14. data/docs/error_handling.html +1609 -0
  15. data/docs/examples.html +702 -0
  16. data/docs/ext_gstate.html +407 -0
  17. data/docs/font_handling.html +669 -0
  18. data/docs/fonts.html +978 -0
  19. data/docs/graphics.html +1210 -0
  20. data/docs/handles.html +204 -0
  21. data/docs/how_to_use.html +371 -0
  22. data/docs/image/Thumbs.db +0 -0
  23. data/docs/image/character_map.png +0 -0
  24. data/docs/image/encoding_list.png +0 -0
  25. data/docs/image/extgtate.png +0 -0
  26. data/docs/image/figure1.png +0 -0
  27. data/docs/image/figure10.png +0 -0
  28. data/docs/image/figure11.png +0 -0
  29. data/docs/image/figure12.png +0 -0
  30. data/docs/image/figure13.png +0 -0
  31. data/docs/image/figure14.png +0 -0
  32. data/docs/image/figure15.png +0 -0
  33. data/docs/image/figure16.png +0 -0
  34. data/docs/image/figure17.png +0 -0
  35. data/docs/image/figure18.png +0 -0
  36. data/docs/image/figure19.png +0 -0
  37. data/docs/image/figure2.png +0 -0
  38. data/docs/image/figure20.png +0 -0
  39. data/docs/image/figure21.png +0 -0
  40. data/docs/image/figure22.png +0 -0
  41. data/docs/image/figure23.png +0 -0
  42. data/docs/image/figure24.png +0 -0
  43. data/docs/image/figure25.png +0 -0
  44. data/docs/image/figure26.png +0 -0
  45. data/docs/image/figure27.png +0 -0
  46. data/docs/image/figure28.png +0 -0
  47. data/docs/image/figure3.png +0 -0
  48. data/docs/image/figure4.png +0 -0
  49. data/docs/image/figure5.png +0 -0
  50. data/docs/image/figure6.png +0 -0
  51. data/docs/image/figure7.png +0 -0
  52. data/docs/image/figure8.png +0 -0
  53. data/docs/image/figure9.png +0 -0
  54. data/docs/image/font_demo.png +0 -0
  55. data/docs/image/harulogo.png +0 -0
  56. data/docs/image/image_demo.png +0 -0
  57. data/docs/image/jpfont_demo.png +0 -0
  58. data/docs/image/line_demo.png +0 -0
  59. data/docs/image/png_demo.png +0 -0
  60. data/docs/image/text_annot.png +0 -0
  61. data/docs/image/text_demo.png +0 -0
  62. data/docs/image/text_demo2.png +0 -0
  63. data/docs/image/tt_font.png +0 -0
  64. data/docs/image_handling.html +505 -0
  65. data/docs/index.html +305 -0
  66. data/docs/install.html +243 -0
  67. data/docs/outline_handling.html +229 -0
  68. data/docs/page_handling.html +2647 -0
  69. data/docs/page_operator.html +2640 -0
  70. data/docs/useful_links.html +203 -0
  71. data/examples/arc_demo.rb +82 -0
  72. data/examples/demo.rb +91 -0
  73. data/examples/encryption.rb +41 -0
  74. data/examples/ext_gstater_demo.rb +171 -0
  75. data/examples/font_demo.rb +67 -0
  76. data/examples/jpfont_demo.rb +122 -0
  77. data/examples/line_demo.rb +301 -0
  78. data/examples/slide_show_demo.rb +139 -0
  79. data/examples/text_demo2.rb +189 -0
  80. data/examples/ttfont_demo.rb +106 -0
  81. data/lib/hpdf.so +0 -0
  82. data/tests/arc_demo.rb +82 -0
  83. data/tests/demo.rb +91 -0
  84. data/tests/encryption.rb +41 -0
  85. data/tests/ext_gstater_demo.rb +171 -0
  86. data/tests/font_demo.rb +67 -0
  87. data/tests/line_demo.rb +301 -0
  88. data/tests/slide_show_demo.rb +139 -0
  89. data/tests/test_all_examples.rb +31 -0
  90. data/tests/text_demo2.rb +189 -0
  91. metadata +137 -0
@@ -0,0 +1,67 @@
1
+ #
2
+ # << Haru Free PDF Library 2.0.0 >> -- font_example.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
+ font_list = ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats", nil]
17
+
18
+ pdf = HPDFDoc.new
19
+
20
+ page = pdf.add_page
21
+ height = page.get_height
22
+ width = page.get_width
23
+
24
+ page.set_line_width(1.0)
25
+ page.rectangle(50.0, 50.0, width - 100.0, height - 110.0)
26
+ page.stroke
27
+
28
+ font1 = pdf.get_font("Helvetica", nil)
29
+
30
+ title = "Font Example"
31
+ page.set_font_and_size(font1, 24.0)
32
+ tw = page.text_width(title)
33
+ page.begin_text
34
+ page.text_out((width - tw) / 2, height - 50.0, title)
35
+ page.set_font_and_size(font1, 16.0)
36
+ page.text_out(60.0, height - 80.0, "<Standerd Type1 fonts samples>")
37
+ page.end_text
38
+
39
+ samp_text = "abcdefgABCDEFG12345!#$\%&+-@?"
40
+
41
+ page.begin_text
42
+ page.move_text_pos(60.0, height - 105.0)
43
+
44
+ i = 0
45
+ while font_list[i]
46
+ font2 = pdf.get_font(font_list[i], nil)
47
+
48
+ page.set_font_and_size(font1, 9.0)
49
+ page.show_text(font_list[i])
50
+ page.move_text_pos(0.0, -18.0)
51
+
52
+ page.set_font_and_size(font2, 20.0)
53
+ page.show_text(samp_text)
54
+ page.move_text_pos(0.0, -20.0)
55
+
56
+ i = i + 1
57
+ end
58
+
59
+ page.end_text
60
+
61
+ if $demo_output_filename
62
+ file_name= $demo_output_filename
63
+ else
64
+ file_name= $0 + ".pdf"
65
+ end
66
+
67
+ pdf.save_to_file(file_name)
@@ -0,0 +1,122 @@
1
+ #
2
+ # << Alternative PDF Library 1.0.0 >> -- font_example.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_TEXT1 = "abcdefgABCDEFG123!#$\%&+-@?"
17
+ SAMP_TEXT2 = "�A�����{�Ԃ��Ȃ����������B�������ɏ��G�r�����悢�ł�B"
18
+
19
+ pdf = HPDFDoc.new
20
+
21
+ pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
22
+ pdf.use_jp_fonts
23
+ pdf.use_jp_encodings
24
+
25
+ title_font = pdf.get_font("Helvetica", nil)
26
+
27
+ font = Array.new(16)
28
+
29
+ font[0] = pdf.get_font("MS-Mincyo", "90ms-RKSJ-H")
30
+ font[1] = pdf.get_font("MS-Mincyo,Bold", "90ms-RKSJ-H")
31
+ font[2] = pdf.get_font("MS-Mincyo,Italic", "90ms-RKSJ-H")
32
+ font[3] = pdf.get_font("MS-Mincyo,BoldItalic", "90ms-RKSJ-H")
33
+ font[4] = pdf.get_font("MS-PMincyo", "90msp-RKSJ-H")
34
+ font[5] = pdf.get_font("MS-PMincyo,Bold", "90msp-RKSJ-H")
35
+ font[6] = pdf.get_font("MS-PMincyo,Italic", "90msp-RKSJ-H")
36
+ font[7] = pdf.get_font("MS-PMincyo,BoldItalic", "90msp-RKSJ-H")
37
+ font[8] = pdf.get_font("MS-Gothic", "90ms-RKSJ-H")
38
+ font[9] = pdf.get_font("MS-Gothic,Bold", "90ms-RKSJ-H")
39
+ font[10] = pdf.get_font("MS-Gothic,Italic", "90ms-RKSJ-H")
40
+ font[11] = pdf.get_font("MS-Gothic,BoldItalic", "90ms-RKSJ-H")
41
+ font[12] = pdf.get_font("MS-PGothic", "90msp-RKSJ-H")
42
+ font[13] = pdf.get_font("MS-PGothic,Bold", "90msp-RKSJ-H")
43
+ font[14] = pdf.get_font("MS-PGothic,Italic", "90msp-RKSJ-H")
44
+ font[15] = pdf.get_font("MS-PGothic,BoldItalic","90msp-RKSJ-H")
45
+
46
+ # set page mode to use outlines.
47
+ pdf.set_page_mode(HPDFDoc::HPDF_PAGE_MODE_USE_OUTLINE)
48
+
49
+ encoder = pdf.get_encoder("90ms-RKSJ-H")
50
+
51
+ # create outline root.
52
+ root = pdf.create_outline(nil, "���{��t�H���g", encoder);
53
+
54
+ i = 0
55
+ while font[i]
56
+ print font[i].get_font_name, "\n"
57
+ page = pdf.add_page
58
+
59
+ outline = pdf.create_outline(root, font[i].get_font_name, nil)
60
+ dst = page.create_destination
61
+ outline.set_destination(dst)
62
+
63
+ page.set_font_and_size(title_font, 10.0)
64
+
65
+ page.begin_text
66
+ page.move_text_pos(10.0, 190.0)
67
+ page.show_text(font[i].get_font_name)
68
+
69
+ page.set_font_and_size(font[i], 15.0)
70
+ page.move_text_pos(10.0, -20.0)
71
+ page.show_text("abcdefghijklmnopqrstuvwxyz")
72
+ page.move_text_pos(0.0, -20.0)
73
+ page.show_text("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
74
+ page.move_text_pos(0.0, -20.0)
75
+ page.show_text("1234567890")
76
+ page.move_text_pos(0.0, -20.0)
77
+
78
+ page.set_font_and_size(font[i], 10.0);
79
+ page.show_text(SAMP_TEXT2)
80
+ page.move_text_pos(0.0, -18.0)
81
+
82
+ page.set_font_and_size(font[i], 16.0);
83
+ page.show_text(SAMP_TEXT2)
84
+ page.move_text_pos(0.0, -27.0)
85
+
86
+ page.set_font_and_size(font[i], 23.0);
87
+ page.show_text(SAMP_TEXT2)
88
+ page.move_text_pos(0.0, -36.0)
89
+
90
+ page.set_font_and_size(font[i], 30.0);
91
+ page.show_text(SAMP_TEXT2)
92
+
93
+ p = page.get_current_text_pos
94
+ page.end_text
95
+
96
+ page.set_width(p[0] + 20)
97
+ page.set_height(210.0)
98
+
99
+ page.set_line_width(0.5)
100
+
101
+ page.move_to(10.0, 185.0)
102
+ page.line_to(p[0] + 10.0, 185.0)
103
+ page.stroke
104
+
105
+ page.move_to(10.0, 125.0)
106
+ page.line_to(p[0] + 10.0, 125.0)
107
+ page.stroke
108
+
109
+ page.move_to(10.0, p[1] - 12.0)
110
+ page.line_to(p[0] + 10.0, p[1] - 12)
111
+ page.stroke
112
+
113
+ i = i + 1
114
+ end
115
+
116
+ if $demo_output_filename
117
+ file_name= $demo_output_filename
118
+ else
119
+ file_name= $0 + ".pdf"
120
+ end
121
+
122
+ pdf.save_to_file(file_name)
@@ -0,0 +1,301 @@
1
+ #
2
+ # << Haru Free PDF Library 2.0.2 >> -- line_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_line(page, x, y, text)
19
+ page.begin_text
20
+ page.move_text_pos(x, y - 10)
21
+ page.show_text(text)
22
+ page.end_text
23
+
24
+ page.move_to(x, y - 15)
25
+ page.line_to(x + 220, y - 15)
26
+ page.stroke
27
+ end
28
+
29
+ def draw_line2(page, x, y, text)
30
+ page.begin_text
31
+ page.move_text_pos(x, y)
32
+ page.show_text(text)
33
+ page.end_text
34
+
35
+ page.move_to(x + 30, y - 25)
36
+ page.line_to(x + 160, y - 25)
37
+ page.stroke
38
+ end
39
+
40
+ def draw_rect(page, x, y, text)
41
+ page.begin_text
42
+ page.move_text_pos(x, y - 10)
43
+ page.show_text(text)
44
+ page.end_text
45
+
46
+ page.rectangle(x, y - 40, 220, 25)
47
+ end
48
+
49
+ pdf = HPDFDoc.new
50
+
51
+ pdf.set_compression_mode(HPDFDoc::HPDF_COMP_ALL)
52
+
53
+ font = pdf.get_font("Helvetica", nil)
54
+
55
+ page = pdf.add_page
56
+
57
+ #print the lines of the page.#
58
+ page.set_line_width(1)
59
+ x = page.get_width - 100
60
+ y = page.get_height - 110
61
+ page.rectangle(50, 50, x, y)
62
+ page.stroke
63
+
64
+ #print the title of the page (with positioning center).#
65
+ page.set_font_and_size(font, 24)
66
+ tw = page.text_width('Line Demo')
67
+ page.begin_text
68
+
69
+ x =(page.get_width - tw) / 2
70
+ y = page.get_height - 50
71
+ page.move_text_pos(x, y)
72
+
73
+ page.show_text('Line Demo')
74
+ page.end_text
75
+
76
+ page.set_font_and_size(font, 10)
77
+
78
+ #Draw verious widths of lines.#
79
+ page.set_line_width(0)
80
+ draw_line(page, 60, 770, 'line width = 0')
81
+
82
+ page.set_line_width(1.0)
83
+ draw_line(page, 60, 740, 'line width = 1.0')
84
+
85
+ page.set_line_width(2.0)
86
+ draw_line(page, 60, 710, 'line width = 2.0')
87
+
88
+ #Line dash pattern#
89
+ page.set_line_width(1.0)
90
+
91
+ page.set_dash([3], 1)
92
+ draw_line(page, 60, 680, 'dash_ptn=[3], phase=1 -- 2 on, 3 off, 3 on...')
93
+
94
+ page.set_dash([7, 3], 2)
95
+ draw_line(page, 60, 650, 'dash_ptn=[7, 3], phase=2 -- 5 on 3 off, 7 on,...')
96
+
97
+ page.set_dash([8, 7, 2, 7], 0)
98
+ draw_line(page, 60, 620, 'dash_ptn=[8, 7, 2, 7], phase=0')
99
+
100
+ page.set_dash([], 0)
101
+
102
+ page.set_line_width(30)
103
+ page.set_rgb_stroke(0.0, 0.5, 0.0)
104
+
105
+ #Line Cap Style#
106
+ page.set_line_cap(HPDFDoc::HPDF_BUTT_END)
107
+ draw_line2(page, 60, 570, 'HPDF_BUTT_END')
108
+
109
+ page.set_line_cap(HPDFDoc::HPDF_ROUND_END)
110
+ draw_line2(page, 60, 505, 'HPDF_ROUND_END')
111
+
112
+ page.set_line_cap(HPDFDoc::HPDF_PROJECTING_SCUARE_END)
113
+ draw_line2(page, 60, 440, 'HPDF_PROJECTING_SCUARE_END')
114
+
115
+ #Line Join Style#
116
+ page.set_line_width(30)
117
+ page.set_rgb_stroke(0.0, 0.0, 0.5)
118
+
119
+ page.set_line_join(HPDFDoc::HPDF_MITER_JOIN)
120
+ page.move_to(120, 300)
121
+ page.line_to(160, 340)
122
+ page.line_to(200, 300)
123
+ page.stroke
124
+
125
+ page.begin_text
126
+ page.move_text_pos(60, 360)
127
+ page.show_text('HPDF_MITER_JOIN')
128
+ page.end_text
129
+
130
+ page.set_line_join(HPDFDoc::HPDF_ROUND_JOIN)
131
+ page.move_to(120, 195)
132
+ page.line_to(160, 235)
133
+ page.line_to(200, 195)
134
+ page.stroke
135
+
136
+ page.begin_text
137
+ page.move_text_pos(60, 255)
138
+ page.show_text('HPDF_ROUND_JOIN')
139
+ page.end_text
140
+
141
+ page.set_line_join(HPDFDoc::HPDF_BEVEL_JOIN)
142
+ page.move_to(120, 90)
143
+ page.line_to(160, 130)
144
+ page.line_to(200, 90)
145
+ page.stroke
146
+
147
+ page.begin_text
148
+ page.move_text_pos(60, 150)
149
+ page.show_text('HPDF_BEVEL_JOIN')
150
+ page.end_text
151
+
152
+ # Draw rectangle #
153
+ page.set_line_width(2)
154
+ page.set_rgb_stroke(0, 0, 0)
155
+ page.set_rgb_fill(0.75, 0.0, 0.0)
156
+
157
+ draw_rect(page, 300, 770, 'stroke')
158
+ page.stroke
159
+
160
+ draw_rect(page, 300, 720, 'Fill')
161
+ page.fill
162
+
163
+ draw_rect(page, 300, 670, 'Fill then stroke')
164
+ page.fill_stroke
165
+
166
+ #clip Rect#
167
+ page.gsave # Save the current graphic state#
168
+ draw_rect(page, 300, 620, 'Clip rectangle')
169
+ page.clip
170
+ page.stroke
171
+ page.set_font_and_size(font, 13)
172
+
173
+ page.begin_text
174
+ page.move_text_pos(290, 600)
175
+ page.set_text_leading(12)
176
+ page.show_text('Clip Clip Clip Clip Clip Clipi Clip Clip Clip')
177
+ page.show_text_next_line('Clip Clip Clip Clip Clip Clip Clip Clip Clip')
178
+ page.show_text_next_line('Clip Clip Clip Clip Clip Clip Clip Clip Clip')
179
+ page.end_text
180
+ page.grestore
181
+
182
+ x0 = 330
183
+ y0 = 440
184
+ x1 = 430
185
+ y1 = 530
186
+ x2 = 480
187
+ y2 = 470
188
+ x3 = 480
189
+ y3 = 90
190
+
191
+ #Curve Example(curve_to2)#
192
+ page.set_rgb_fill(0, 0, 0)
193
+
194
+ page.begin_text
195
+ page.move_text_pos(300, 540)
196
+ page.show_text('curve_to2(x1, y1, x2. y2)')
197
+ page.end_text
198
+
199
+ page.begin_text
200
+ page.move_text_pos(x0 + 5, y0 - 5)
201
+ page.show_text('Current point')
202
+ page.move_text_pos(x1 - x0, y1 - y0)
203
+ page.show_text('(x1, y1)')
204
+ page.move_text_pos(x2 - x1, y2 - y1)
205
+ page.show_text('(x2, y2)')
206
+ page.end_text
207
+
208
+ page.set_dash([], 0)
209
+
210
+ page.set_line_width(0.5)
211
+ page.move_to(x1, y1)
212
+ page.line_to(x2, y2)
213
+ page.stroke
214
+
215
+ page.set_dash([], 0)
216
+
217
+ page.set_line_width(1.5)
218
+
219
+ page.move_to(x0, y0)
220
+ page.curve_to2(x1, y1, x2, y2)
221
+ page.stroke
222
+
223
+ #Curve Example(curve_to3)#
224
+ y0 = y0 - 150
225
+ y1 = y1 - 150
226
+ y2 = y2 - 150
227
+
228
+ page.begin_text
229
+ page.move_text_pos(300, 390)
230
+ page.show_text('curve_to3(x1, y1, x2. y2)')
231
+ page.end_text
232
+
233
+ page.begin_text
234
+ page.move_text_pos(x0 + 5, y0 - 5)
235
+ page.show_text('Current point')
236
+ page.move_text_pos(x1 - x0, y1 - y0)
237
+ page.show_text('(x1, y1)')
238
+ page.move_text_pos(x2 - x1, y2 - y1)
239
+ page.show_text('(x2, y2)')
240
+ page.end_text
241
+
242
+ page.set_dash([3], 1)
243
+
244
+ page.set_line_width(0.5)
245
+ page.move_to(x0, y0)
246
+ page.line_to(x1, y1)
247
+ page.stroke
248
+
249
+ page.set_dash([], 0)
250
+
251
+ page.set_line_width(1.5)
252
+ page.move_to(x0, y0)
253
+ page.curve_to3(x1, y1, x2, y2)
254
+ page.stroke
255
+
256
+ # Curve Example(curve_to)
257
+ y0 = y0 - 150
258
+ y1 = y1 - 160
259
+ y2 = y2 - 130
260
+ x2 = x2 + 10
261
+
262
+ page.begin_text
263
+ page.move_text_pos(300, 240)
264
+ page.show_text('curve_to(x1, y1, x2. y2, x3, y3)')
265
+ page.end_text
266
+
267
+ page.begin_text
268
+ page.move_text_pos(x0 + 5, y0 - 5)
269
+ page.show_text('Current point')
270
+ page.move_text_pos(x1 - x0, y1 - y0)
271
+ page.show_text('(x1, y1)')
272
+ page.move_text_pos(x2 - x1, y2 - y1)
273
+ page.show_text('(x2, y2)')
274
+ page.move_text_pos(x3 - x2, y3 - y2)
275
+ page.show_text('(x3, y3)')
276
+ page.end_text
277
+
278
+ page.set_dash([3], 1)
279
+
280
+ page.set_line_width(0.5)
281
+ page.move_to(x0, y0)
282
+ page.line_to(x1, y1)
283
+ page.stroke
284
+ page.move_to(x2, y2)
285
+ page.line_to(x3, y3)
286
+ page.stroke
287
+
288
+ page.set_dash([], 0)
289
+
290
+ page.set_line_width(1.5)
291
+ page.move_to(x0, y0)
292
+ page.curve_to(x1, y1, x2, y2, x3, y3)
293
+ page.stroke
294
+
295
+ if $demo_output_filename
296
+ file_name= $demo_output_filename
297
+ else
298
+ file_name= $0 + ".pdf"
299
+ end
300
+
301
+ pdf.save_to_file(file_name)