hpdf 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/History +57 -0
  2. data/License +25 -0
  3. data/README +165 -0
  4. data/examples/arc_demo.rb +82 -0
  5. data/examples/demo.rb +92 -0
  6. data/examples/encryption.rb +41 -0
  7. data/examples/ext_gstater_demo.rb +171 -0
  8. data/examples/font_demo.rb +67 -0
  9. data/examples/jpfont_demo.rb +122 -0
  10. data/examples/line_demo.rb +301 -0
  11. data/examples/slide_show_demo.rb +139 -0
  12. data/examples/text_demo2.rb +189 -0
  13. data/examples/ttfont_demo.rb +106 -0
  14. data/ext/extconf.rb +6 -0
  15. data/ext/hpdf.c +3779 -0
  16. data/ext/hpdf_annotation.c +415 -0
  17. data/ext/hpdf_array.c +344 -0
  18. data/ext/hpdf_binary.c +117 -0
  19. data/ext/hpdf_boolean.c +47 -0
  20. data/ext/hpdf_catalog.c +354 -0
  21. data/ext/hpdf_destination.c +339 -0
  22. data/ext/hpdf_dict.c +488 -0
  23. data/ext/hpdf_doc.c +2020 -0
  24. data/ext/hpdf_doc_png.c +137 -0
  25. data/ext/hpdf_encoder.c +2991 -0
  26. data/ext/hpdf_encoder_cns.c +36359 -0
  27. data/ext/hpdf_encoder_cnt.c +15307 -0
  28. data/ext/hpdf_encoder_jp.c +16125 -0
  29. data/ext/hpdf_encoder_kr.c +27978 -0
  30. data/ext/hpdf_encrypt.c +632 -0
  31. data/ext/hpdf_encryptdict.c +240 -0
  32. data/ext/hpdf_error.c +114 -0
  33. data/ext/hpdf_ext_gstate.c +150 -0
  34. data/ext/hpdf_font.c +229 -0
  35. data/ext/hpdf_font_cid.c +1030 -0
  36. data/ext/hpdf_font_tt.c +406 -0
  37. data/ext/hpdf_font_type1.c +391 -0
  38. data/ext/hpdf_fontdef.c +56 -0
  39. data/ext/hpdf_fontdef_base14.c +4506 -0
  40. data/ext/hpdf_fontdef_cid.c +194 -0
  41. data/ext/hpdf_fontdef_cns.c +471 -0
  42. data/ext/hpdf_fontdef_cnt.c +250 -0
  43. data/ext/hpdf_fontdef_jp.c +1904 -0
  44. data/ext/hpdf_fontdef_kr.c +1572 -0
  45. data/ext/hpdf_fontdef_tt.c +2230 -0
  46. data/ext/hpdf_fontdef_type1.c +524 -0
  47. data/ext/hpdf_gstate.c +119 -0
  48. data/ext/hpdf_image.c +568 -0
  49. data/ext/hpdf_image_png.c +424 -0
  50. data/ext/hpdf_info.c +164 -0
  51. data/ext/hpdf_list.c +333 -0
  52. data/ext/hpdf_mmgr.c +243 -0
  53. data/ext/hpdf_name.c +71 -0
  54. data/ext/hpdf_null.c +31 -0
  55. data/ext/hpdf_number.c +49 -0
  56. data/ext/hpdf_objects.c +172 -0
  57. data/ext/hpdf_outline.c +329 -0
  58. data/ext/hpdf_page_label.c +74 -0
  59. data/ext/hpdf_page_operator.c +2764 -0
  60. data/ext/hpdf_pages.c +1508 -0
  61. data/ext/hpdf_real.c +61 -0
  62. data/ext/hpdf_streams.c +1435 -0
  63. data/ext/hpdf_string.c +189 -0
  64. data/ext/hpdf_utils.c +438 -0
  65. data/ext/hpdf_xref.c +348 -0
  66. data/ext/include/hpdf.h +1227 -0
  67. data/ext/include/hpdf_annotation.h +74 -0
  68. data/ext/include/hpdf_catalog.h +81 -0
  69. data/ext/include/hpdf_conf.h +76 -0
  70. data/ext/include/hpdf_consts.h +549 -0
  71. data/ext/include/hpdf_destination.h +41 -0
  72. data/ext/include/hpdf_doc.h +159 -0
  73. data/ext/include/hpdf_encoder.h +311 -0
  74. data/ext/include/hpdf_encrypt.h +156 -0
  75. data/ext/include/hpdf_encryptdict.h +66 -0
  76. data/ext/include/hpdf_error.h +201 -0
  77. data/ext/include/hpdf_ext_gstate.h +38 -0
  78. data/ext/include/hpdf_font.h +112 -0
  79. data/ext/include/hpdf_fontdef.h +403 -0
  80. data/ext/include/hpdf_gstate.h +80 -0
  81. data/ext/include/hpdf_image.h +72 -0
  82. data/ext/include/hpdf_info.h +48 -0
  83. data/ext/include/hpdf_list.h +85 -0
  84. data/ext/include/hpdf_mmgr.h +82 -0
  85. data/ext/include/hpdf_objects.h +587 -0
  86. data/ext/include/hpdf_outline.h +74 -0
  87. data/ext/include/hpdf_page_label.h +35 -0
  88. data/ext/include/hpdf_pages.h +128 -0
  89. data/ext/include/hpdf_streams.h +276 -0
  90. data/ext/include/hpdf_types.h +488 -0
  91. data/ext/include/hpdf_utils.h +161 -0
  92. data/tests/arc_demo.rb +82 -0
  93. data/tests/demo.rb +91 -0
  94. data/tests/encryption.rb +41 -0
  95. data/tests/ext_gstater_demo.rb +171 -0
  96. data/tests/font_demo.rb +67 -0
  97. data/tests/line_demo.rb +301 -0
  98. data/tests/slide_show_demo.rb +139 -0
  99. data/tests/test_all_examples.rb +31 -0
  100. data/tests/text_demo2.rb +189 -0
  101. metadata +147 -0
@@ -0,0 +1,31 @@
1
+ require 'test/unit'
2
+ require 'fileutils'
3
+
4
+ class TestAllExamples < Test::Unit::TestCase
5
+
6
+ def test_all_examples
7
+
8
+ examples_path = File.join(File.dirname(__FILE__), '*.rb')
9
+
10
+ programs= Dir[examples_path]
11
+
12
+ programs.each do |prog_name|
13
+
14
+ next if File.basename(prog_name) == "test_all_examples.rb"
15
+
16
+ pdf_file= File.basename(prog_name) + ".pdf"
17
+
18
+ print "Generating #{pdf_file}..."
19
+
20
+ $demo_output_filename= pdf_file
21
+ require(prog_name)
22
+
23
+ assert File.exist?(pdf_file)
24
+
25
+ FileUtils.rm pdf_file, :force => true
26
+
27
+ puts "done."
28
+ end
29
+ end
30
+ end
31
+
@@ -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)
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: hpdf
5
+ version: !ruby/object:Gem::Version
6
+ version: 2.0.8
7
+ date: 2007-09-07 00:00:00 -03:00
8
+ summary: "Bindings for libharu2: a C language PDF generation library."
9
+ require_paths:
10
+ - lib
11
+ email: oga_emmanuel_oga@yahoo.com.ar
12
+ homepage: http://emmanueloga.blogspot.com
13
+ rubyforge_project: hpdf
14
+ description:
15
+ autorequire: hpdf
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Takeshi Kanno
31
+ - Emmanuel Oga
32
+ files:
33
+ - examples/arc_demo.rb
34
+ - examples/demo.rb
35
+ - examples/line_demo.rb
36
+ - examples/font_demo.rb
37
+ - examples/encryption.rb
38
+ - examples/ttfont_demo.rb
39
+ - examples/jpfont_demo.rb
40
+ - examples/ext_gstater_demo.rb
41
+ - examples/text_demo2.rb
42
+ - examples/slide_show_demo.rb
43
+ - tests/arc_demo.rb
44
+ - tests/demo.rb
45
+ - tests/line_demo.rb
46
+ - tests/font_demo.rb
47
+ - tests/encryption.rb
48
+ - tests/test_all_examples.rb
49
+ - tests/ext_gstater_demo.rb
50
+ - tests/text_demo2.rb
51
+ - tests/slide_show_demo.rb
52
+ - ext/hpdf_doc_png.c
53
+ - ext/hpdf_list.c
54
+ - ext/hpdf_encoder_kr.c
55
+ - ext/hpdf_fontdef_cnt.c
56
+ - ext/hpdf_info.c
57
+ - ext/hpdf_utils.c
58
+ - ext/hpdf_encoder_jp.c
59
+ - ext/hpdf_streams.c
60
+ - ext/hpdf_error.c
61
+ - ext/hpdf_encryptdict.c
62
+ - ext/hpdf_fontdef_cns.c
63
+ - ext/include
64
+ - ext/hpdf_encoder_cnt.c
65
+ - ext/hpdf_number.c
66
+ - ext/hpdf_image.c
67
+ - ext/hpdf_fontdef_base14.c
68
+ - ext/hpdf_encrypt.c
69
+ - ext/hpdf_page_label.c
70
+ - ext/hpdf_fontdef.c
71
+ - ext/hpdf_name.c
72
+ - ext/hpdf_dict.c
73
+ - ext/hpdf_destination.c
74
+ - ext/hpdf_page_operator.c
75
+ - ext/hpdf_boolean.c
76
+ - ext/hpdf_catalog.c
77
+ - ext/hpdf_encoder_cns.c
78
+ - ext/extconf.rb
79
+ - ext/hpdf_string.c
80
+ - ext/hpdf_gstate.c
81
+ - ext/hpdf_xref.c
82
+ - ext/hpdf.c
83
+ - ext/hpdf_font.c
84
+ - ext/hpdf_fontdef_type1.c
85
+ - ext/hpdf_encoder.c
86
+ - ext/hpdf_pages.c
87
+ - ext/hpdf_objects.c
88
+ - ext/hpdf_binary.c
89
+ - ext/hpdf_annotation.c
90
+ - ext/hpdf_doc.c
91
+ - ext/hpdf_real.c
92
+ - ext/hpdf_mmgr.c
93
+ - ext/hpdf_fontdef_tt.c
94
+ - ext/hpdf_fontdef_kr.c
95
+ - ext/hpdf_font_type1.c
96
+ - ext/hpdf_image_png.c
97
+ - ext/hpdf_font_cid.c
98
+ - ext/hpdf_null.c
99
+ - ext/hpdf_ext_gstate.c
100
+ - ext/hpdf_array.c
101
+ - ext/hpdf_fontdef_jp.c
102
+ - ext/hpdf_outline.c
103
+ - ext/hpdf_fontdef_cid.c
104
+ - ext/hpdf_font_tt.c
105
+ - ext/include/hpdf_info.h
106
+ - ext/include/hpdf_page_label.h
107
+ - ext/include/hpdf_utils.h
108
+ - ext/include/hpdf_mmgr.h
109
+ - ext/include/hpdf_consts.h
110
+ - ext/include/hpdf_objects.h
111
+ - ext/include/hpdf_error.h
112
+ - ext/include/hpdf_types.h
113
+ - ext/include/hpdf_conf.h
114
+ - ext/include/hpdf_list.h
115
+ - ext/include/hpdf_encryptdict.h
116
+ - ext/include/hpdf_ext_gstate.h
117
+ - ext/include/hpdf_encrypt.h
118
+ - ext/include/hpdf_font.h
119
+ - ext/include/hpdf_fontdef.h
120
+ - ext/include/hpdf_image.h
121
+ - ext/include/hpdf_doc.h
122
+ - ext/include/hpdf_encoder.h
123
+ - ext/include/hpdf_gstate.h
124
+ - ext/include/hpdf.h
125
+ - ext/include/hpdf_pages.h
126
+ - ext/include/hpdf_streams.h
127
+ - ext/include/hpdf_outline.h
128
+ - ext/include/hpdf_annotation.h
129
+ - ext/include/hpdf_catalog.h
130
+ - ext/include/hpdf_destination.h
131
+ - README
132
+ - History
133
+ - License
134
+ test_files:
135
+ - tests/test_all_examples.rb
136
+ rdoc_options: []
137
+
138
+ extra_rdoc_files:
139
+ - README
140
+ executables: []
141
+
142
+ extensions:
143
+ - ext/extconf.rb
144
+ requirements:
145
+ - libpng and zlib
146
+ dependencies: []
147
+