hpdf 2.0.8

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.
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,74 @@
1
+ /*
2
+ * << Haru Free PDF Library 2.0.0 >> -- hpdf_outline.h
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
+
15
+ #ifndef _HPDF_OUTLINE_H
16
+ #define _HPDF_OUTLINE_H
17
+
18
+ #include "hpdf_objects.h"
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+
25
+ /*----------------------------------------------------------------------------*/
26
+ /*----- HPDF_Outline ---------------------------------------------------------*/
27
+
28
+ HPDF_Outline
29
+ HPDF_OutlineRoot_New (HPDF_MMgr mmgr,
30
+ HPDF_Xref xref);
31
+
32
+
33
+ HPDF_Outline
34
+ HPDF_Outline_New (HPDF_MMgr mmgr,
35
+ HPDF_Outline parent,
36
+ const char *title,
37
+ HPDF_Encoder encoder,
38
+ HPDF_Xref xref);
39
+
40
+
41
+ HPDF_Outline
42
+ HPDF_Outline_GetFirst (HPDF_Outline outline);
43
+
44
+
45
+ HPDF_Outline
46
+ HPDF_Outline_GetLast (HPDF_Outline outline);
47
+
48
+
49
+ HPDF_Outline
50
+ HPDF_Outline_GetPrev(HPDF_Outline outline);
51
+
52
+
53
+ HPDF_Outline
54
+ HPDF_Outline_GetNext (HPDF_Outline outline);
55
+
56
+
57
+ HPDF_Outline
58
+ HPDF_Outline_GetParent (HPDF_Outline outline);
59
+
60
+
61
+ HPDF_BOOL
62
+ HPDF_Outline_GetOpened (HPDF_Outline outline);
63
+
64
+
65
+
66
+ HPDF_BOOL
67
+ HPDF_Outline_Validate (HPDF_Outline obj);
68
+
69
+ #ifdef __cplusplus
70
+ }
71
+ #endif /* __cplusplus */
72
+
73
+ #endif /* _HPDF_OUTLINE_H */
74
+
@@ -0,0 +1,35 @@
1
+ /*
2
+ * << Haru Free PDF Library 2.0.0 >> -- hpdf_page_label.h
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
+
15
+ #ifndef _HPDF_PAGE_LABEL_H
16
+ #define _HPDF_PAGE_LABEL_H
17
+
18
+ #include "hpdf.h"
19
+
20
+ #ifdef __cplusplus
21
+ extern "C" {
22
+ #endif
23
+
24
+ HPDF_Dict
25
+ HPDF_PageLabel_New (HPDF_Doc pdf,
26
+ HPDF_PageNumStyle style,
27
+ HPDF_INT first_page,
28
+ const char *prefix);
29
+
30
+ #ifdef __cplusplus
31
+ }
32
+ #endif /* __cplusplus */
33
+
34
+ #endif
35
+
@@ -0,0 +1,128 @@
1
+ /*
2
+ * << Haru Free PDF Library 2.0.0 >> -- hpdf_pages.c
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
+
15
+ #ifndef _HPDF_PAGES_H
16
+ #define _HPDF_PAGES_H
17
+
18
+ #include "hpdf_gstate.h"
19
+ #include "hpdf_ext_gstate.h"
20
+
21
+ #ifdef __cplusplus
22
+ extern "C" {
23
+ #endif
24
+
25
+ /*----------------------------------------------------------------------------*/
26
+ /*----- HPDF_Pages -----------------------------------------------------------*/
27
+
28
+ HPDF_Pages
29
+ HPDF_Pages_New (HPDF_MMgr mmgr,
30
+ HPDF_Pages parent,
31
+ HPDF_Xref xref);
32
+
33
+
34
+ HPDF_BOOL
35
+ HPDF_Pages_Validate (HPDF_Pages pages);
36
+
37
+
38
+ HPDF_STATUS
39
+ HPDF_Pages_AddKids (HPDF_Pages parent,
40
+ HPDF_Dict kid);
41
+
42
+
43
+ HPDF_STATUS
44
+ HPDF_Page_InsertBefore (HPDF_Page page,
45
+ HPDF_Page target);
46
+
47
+
48
+ typedef struct _HPDF_PageAttr_Rec *HPDF_PageAttr;
49
+
50
+ typedef struct _HPDF_PageAttr_Rec {
51
+ HPDF_Pages parent;
52
+ HPDF_Dict fonts;
53
+ HPDF_Dict xobjects;
54
+ HPDF_Dict ext_gstates;
55
+ HPDF_GState gstate;
56
+ HPDF_Point str_pos;
57
+ HPDF_Point cur_pos;
58
+ HPDF_Point text_pos;
59
+ HPDF_TransMatrix text_matrix;
60
+ HPDF_UINT16 gmode;
61
+ HPDF_Dict contents;
62
+ HPDF_Stream stream;
63
+ HPDF_Xref xref;
64
+ HPDF_UINT compression_mode;
65
+ HPDF_PDFVer *ver;
66
+ } HPDF_PageAttr_Rec;
67
+
68
+
69
+ /*----------------------------------------------------------------------------*/
70
+ /*----- HPDF_Page ------------------------------------------------------------*/
71
+
72
+ HPDF_BOOL
73
+ HPDF_Page_Validate (HPDF_Page page);
74
+
75
+
76
+ HPDF_Page
77
+ HPDF_Page_New (HPDF_MMgr mmgr,
78
+ HPDF_Xref xref);
79
+
80
+
81
+ void*
82
+ HPDF_Page_GetInheritableItem (HPDF_Page page,
83
+ const char *key,
84
+ HPDF_UINT16 obj_class);
85
+
86
+
87
+ const char*
88
+ HPDF_Page_GetXObjectName (HPDF_Page page,
89
+ HPDF_XObject xobj);
90
+
91
+
92
+ const char*
93
+ HPDF_Page_GetLocalFontName (HPDF_Page page,
94
+ HPDF_Font font);
95
+
96
+
97
+ const char*
98
+ HPDF_Page_GetExtGStateName (HPDF_Page page,
99
+ HPDF_ExtGState gstate);
100
+
101
+
102
+ HPDF_Box
103
+ HPDF_Page_GetMediaBox (HPDF_Page page);
104
+
105
+
106
+ HPDF_STATUS
107
+ HPDF_Page_SetBoxValue (HPDF_Page page,
108
+ const char *name,
109
+ HPDF_UINT index,
110
+ HPDF_REAL value);
111
+
112
+
113
+ void
114
+ HPDF_Page_SetFilter (HPDF_Page page,
115
+ HPDF_UINT filter);
116
+
117
+
118
+ HPDF_STATUS
119
+ HPDF_Page_CheckState (HPDF_Page page,
120
+ HPDF_UINT mode);
121
+
122
+
123
+ #ifdef __cplusplus
124
+ }
125
+ #endif /* __cplusplus */
126
+
127
+ #endif /* _HPDF_PAGES_H */
128
+
@@ -0,0 +1,276 @@
1
+ /*
2
+ * << Haru Free PDF Library 2.0.3 >> -- hpdf_streams.h
3
+ *
4
+ * Copyright (c) 1999-2004 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
+ * 2005.12.20 Created.
14
+ *
15
+ */
16
+
17
+ #ifndef _HPDF_STREAMS_H
18
+ #define _HPDF_STREAMS_H
19
+
20
+ #include "hpdf_list.h"
21
+ #include "hpdf_encrypt.h"
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+
28
+ #define HPDF_STREAM_SIG_BYTES 0x5354524DL
29
+
30
+ typedef enum _HPDF_StreamType {
31
+ HPDF_STREAM_UNKNOWN = 0,
32
+ HPDF_STREAM_CALLBACK,
33
+ HPDF_STREAM_FILE,
34
+ HPDF_STREAM_MEMORY,
35
+ } HPDF_StreamType;
36
+
37
+ #define HPDF_STREAM_FILTER_NONE 0x0000
38
+ #define HPDF_STREAM_FILTER_ASCIIHEX 0x0100
39
+ #define HPDF_STREAM_FILTER_ASCII85 0x0200
40
+ #define HPDF_STREAM_FILTER_FLATE_DECODE 0x0400
41
+ #define HPDF_STREAM_FILTER_DCT_DECODE 0x0800
42
+
43
+ typedef enum _HPDF_WhenceMode {
44
+ HPDF_SEEK_SET = 0,
45
+ HPDF_SEEK_CUR,
46
+ HPDF_SEEK_END
47
+ } HPDF_WhenceMode;
48
+
49
+ typedef struct _HPDF_Stream_Rec *HPDF_Stream;
50
+
51
+ typedef HPDF_STATUS
52
+ (*HPDF_Stream_Write_Func) (HPDF_Stream stream,
53
+ const HPDF_BYTE *ptr,
54
+ HPDF_UINT siz);
55
+
56
+
57
+ typedef HPDF_STATUS
58
+ (*HPDF_Stream_Read_Func) (HPDF_Stream stream,
59
+ HPDF_BYTE *ptr,
60
+ HPDF_UINT *siz);
61
+
62
+
63
+ typedef HPDF_STATUS
64
+ (*HPDF_Stream_Seek_Func) (HPDF_Stream stream,
65
+ HPDF_INT pos,
66
+ HPDF_WhenceMode mode);
67
+
68
+
69
+ typedef HPDF_INT32
70
+ (*HPDF_Stream_Tell_Func) (HPDF_Stream stream);
71
+
72
+
73
+ typedef void
74
+ (*HPDF_Stream_Free_Func) (HPDF_Stream stream);
75
+
76
+
77
+ typedef HPDF_UINT32
78
+ (*HPDF_Stream_Size_Func) (HPDF_Stream stream);
79
+
80
+
81
+ typedef struct _HPDF_MemStreamAttr_Rec *HPDF_MemStreamAttr;
82
+
83
+
84
+ typedef struct _HPDF_MemStreamAttr_Rec {
85
+ HPDF_List buf;
86
+ HPDF_UINT buf_siz;
87
+ HPDF_UINT w_pos;
88
+ HPDF_BYTE *w_ptr;
89
+ HPDF_UINT r_ptr_idx;
90
+ HPDF_UINT r_pos;
91
+ HPDF_BYTE *r_ptr;
92
+ } HPDF_MemStreamAttr_Rec;
93
+
94
+
95
+ typedef struct _HPDF_Stream_Rec {
96
+ HPDF_UINT32 sig_bytes;
97
+ HPDF_StreamType type;
98
+ HPDF_MMgr mmgr;
99
+ HPDF_Error error;
100
+ HPDF_UINT size;
101
+ HPDF_Stream_Write_Func write_fn;
102
+ HPDF_Stream_Read_Func read_fn;
103
+ HPDF_Stream_Seek_Func seek_fn;
104
+ HPDF_Stream_Free_Func free_fn;
105
+ HPDF_Stream_Tell_Func tell_fn;
106
+ HPDF_Stream_Size_Func size_fn;
107
+ void* attr;
108
+ } HPDF_Stream_Rec;
109
+
110
+
111
+
112
+ HPDF_Stream
113
+ HPDF_MemStream_New (HPDF_MMgr mmgr,
114
+ HPDF_UINT buf_siz);
115
+
116
+
117
+ HPDF_BYTE*
118
+ HPDF_MemStream_GetBufPtr (HPDF_Stream stream,
119
+ HPDF_UINT index,
120
+ HPDF_UINT *length);
121
+
122
+
123
+ HPDF_UINT
124
+ HPDF_MemStream_GetBufSize (HPDF_Stream stream);
125
+
126
+
127
+ HPDF_UINT
128
+ HPDF_MemStream_GetBufCount (HPDF_Stream stream);
129
+
130
+
131
+ HPDF_STATUS
132
+ HPDF_MemStream_Rewrite (HPDF_Stream stream,
133
+ HPDF_BYTE *buf,
134
+ HPDF_UINT size);
135
+
136
+
137
+ void
138
+ HPDF_MemStream_FreeData (HPDF_Stream stream);
139
+
140
+
141
+ HPDF_STATUS
142
+ HPDF_Stream_WriteToStream (HPDF_Stream src,
143
+ HPDF_Stream dst,
144
+ HPDF_UINT filter,
145
+ HPDF_Encrypt e);
146
+
147
+
148
+ HPDF_Stream
149
+ HPDF_FileReader_New (HPDF_MMgr mmgr,
150
+ const char *fname);
151
+
152
+
153
+ HPDF_Stream
154
+ HPDF_FileWriter_New (HPDF_MMgr mmgr,
155
+ const char *fname);
156
+
157
+
158
+ HPDF_Stream
159
+ HPDF_CallbackReader_New (HPDF_MMgr mmgr,
160
+ HPDF_Stream_Read_Func read_fn,
161
+ HPDF_Stream_Seek_Func seek_fn,
162
+ HPDF_Stream_Tell_Func tell_fn,
163
+ HPDF_Stream_Size_Func size_fn,
164
+ void* data);
165
+
166
+
167
+ HPDF_Stream
168
+ HPDF_CallbackWriter_New (HPDF_MMgr mmgr,
169
+ HPDF_Stream_Write_Func write_fn,
170
+ void* data);
171
+
172
+
173
+ void
174
+ HPDF_Stream_Free (HPDF_Stream stream);
175
+
176
+
177
+ HPDF_STATUS
178
+ HPDF_Stream_WriteChar (HPDF_Stream stream,
179
+ char value);
180
+
181
+
182
+ HPDF_STATUS
183
+ HPDF_Stream_WriteStr (HPDF_Stream stream,
184
+ const char *value);
185
+
186
+
187
+ HPDF_STATUS
188
+ HPDF_Stream_WriteUChar (HPDF_Stream stream,
189
+ HPDF_BYTE value);
190
+
191
+
192
+ HPDF_STATUS
193
+ HPDF_Stream_WriteInt (HPDF_Stream stream,
194
+ HPDF_INT value);
195
+
196
+
197
+ HPDF_STATUS
198
+ HPDF_Stream_WriteUInt (HPDF_Stream stream,
199
+ HPDF_UINT value);
200
+
201
+
202
+ HPDF_STATUS
203
+ HPDF_Stream_WriteReal (HPDF_Stream stream,
204
+ HPDF_REAL value);
205
+
206
+
207
+ HPDF_STATUS
208
+ HPDF_Stream_Write (HPDF_Stream stream,
209
+ const HPDF_BYTE *ptr,
210
+ HPDF_UINT size);
211
+
212
+
213
+ HPDF_STATUS
214
+ HPDF_Stream_Read (HPDF_Stream stream,
215
+ HPDF_BYTE *ptr,
216
+ HPDF_UINT *size);
217
+
218
+ HPDF_STATUS
219
+ HPDF_Stream_ReadLn (HPDF_Stream stream,
220
+ char *s,
221
+ HPDF_UINT *size);
222
+
223
+
224
+ HPDF_INT32
225
+ HPDF_Stream_Tell (HPDF_Stream stream);
226
+
227
+
228
+ HPDF_STATUS
229
+ HPDF_Stream_Seek (HPDF_Stream stream,
230
+ HPDF_INT pos,
231
+ HPDF_WhenceMode mode);
232
+
233
+
234
+ HPDF_BOOL
235
+ HPDF_Stream_EOF (HPDF_Stream stream);
236
+
237
+
238
+ HPDF_UINT32
239
+ HPDF_Stream_Size (HPDF_Stream stream);
240
+
241
+ HPDF_STATUS
242
+ HPDF_Stream_Flush (HPDF_Stream stream);
243
+
244
+
245
+ HPDF_STATUS
246
+ HPDF_Stream_WriteEscapeName (HPDF_Stream stream,
247
+ const char *value);
248
+
249
+
250
+ HPDF_STATUS
251
+ HPDF_Stream_WriteEscapeText2 (HPDF_Stream stream,
252
+ const char *text,
253
+ HPDF_UINT len);
254
+
255
+
256
+ HPDF_STATUS
257
+ HPDF_Stream_WriteEscapeText (HPDF_Stream stream,
258
+ const char *text);
259
+
260
+
261
+ HPDF_STATUS
262
+ HPDF_Stream_WriteBinary (HPDF_Stream stream,
263
+ const HPDF_BYTE *data,
264
+ HPDF_UINT len,
265
+ HPDF_Encrypt e);
266
+
267
+
268
+ HPDF_STATUS
269
+ HPDF_Stream_Validate (HPDF_Stream stream);
270
+
271
+
272
+ #ifdef __cplusplus
273
+ }
274
+ #endif /* __cplusplus */
275
+
276
+ #endif /* _HPDF_STREAMS_H */