hpdf 2.0.8
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 +165 -0
- data/examples/arc_demo.rb +82 -0
- data/examples/demo.rb +92 -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/ext/extconf.rb +6 -0
- data/ext/hpdf.c +3779 -0
- data/ext/hpdf_annotation.c +415 -0
- data/ext/hpdf_array.c +344 -0
- data/ext/hpdf_binary.c +117 -0
- data/ext/hpdf_boolean.c +47 -0
- data/ext/hpdf_catalog.c +354 -0
- data/ext/hpdf_destination.c +339 -0
- data/ext/hpdf_dict.c +488 -0
- data/ext/hpdf_doc.c +2020 -0
- data/ext/hpdf_doc_png.c +137 -0
- data/ext/hpdf_encoder.c +2991 -0
- data/ext/hpdf_encoder_cns.c +36359 -0
- data/ext/hpdf_encoder_cnt.c +15307 -0
- data/ext/hpdf_encoder_jp.c +16125 -0
- data/ext/hpdf_encoder_kr.c +27978 -0
- data/ext/hpdf_encrypt.c +632 -0
- data/ext/hpdf_encryptdict.c +240 -0
- data/ext/hpdf_error.c +114 -0
- data/ext/hpdf_ext_gstate.c +150 -0
- data/ext/hpdf_font.c +229 -0
- data/ext/hpdf_font_cid.c +1030 -0
- data/ext/hpdf_font_tt.c +406 -0
- data/ext/hpdf_font_type1.c +391 -0
- data/ext/hpdf_fontdef.c +56 -0
- data/ext/hpdf_fontdef_base14.c +4506 -0
- data/ext/hpdf_fontdef_cid.c +194 -0
- data/ext/hpdf_fontdef_cns.c +471 -0
- data/ext/hpdf_fontdef_cnt.c +250 -0
- data/ext/hpdf_fontdef_jp.c +1904 -0
- data/ext/hpdf_fontdef_kr.c +1572 -0
- data/ext/hpdf_fontdef_tt.c +2230 -0
- data/ext/hpdf_fontdef_type1.c +524 -0
- data/ext/hpdf_gstate.c +119 -0
- data/ext/hpdf_image.c +568 -0
- data/ext/hpdf_image_png.c +424 -0
- data/ext/hpdf_info.c +164 -0
- data/ext/hpdf_list.c +333 -0
- data/ext/hpdf_mmgr.c +243 -0
- data/ext/hpdf_name.c +71 -0
- data/ext/hpdf_null.c +31 -0
- data/ext/hpdf_number.c +49 -0
- data/ext/hpdf_objects.c +172 -0
- data/ext/hpdf_outline.c +329 -0
- data/ext/hpdf_page_label.c +74 -0
- data/ext/hpdf_page_operator.c +2764 -0
- data/ext/hpdf_pages.c +1508 -0
- data/ext/hpdf_real.c +61 -0
- data/ext/hpdf_streams.c +1435 -0
- data/ext/hpdf_string.c +189 -0
- data/ext/hpdf_utils.c +438 -0
- data/ext/hpdf_xref.c +348 -0
- data/ext/include/hpdf.h +1227 -0
- data/ext/include/hpdf_annotation.h +74 -0
- data/ext/include/hpdf_catalog.h +81 -0
- data/ext/include/hpdf_conf.h +76 -0
- data/ext/include/hpdf_consts.h +549 -0
- data/ext/include/hpdf_destination.h +41 -0
- data/ext/include/hpdf_doc.h +159 -0
- data/ext/include/hpdf_encoder.h +311 -0
- data/ext/include/hpdf_encrypt.h +156 -0
- data/ext/include/hpdf_encryptdict.h +66 -0
- data/ext/include/hpdf_error.h +201 -0
- data/ext/include/hpdf_ext_gstate.h +38 -0
- data/ext/include/hpdf_font.h +112 -0
- data/ext/include/hpdf_fontdef.h +403 -0
- data/ext/include/hpdf_gstate.h +80 -0
- data/ext/include/hpdf_image.h +72 -0
- data/ext/include/hpdf_info.h +48 -0
- data/ext/include/hpdf_list.h +85 -0
- data/ext/include/hpdf_mmgr.h +82 -0
- data/ext/include/hpdf_objects.h +587 -0
- data/ext/include/hpdf_outline.h +74 -0
- data/ext/include/hpdf_page_label.h +35 -0
- data/ext/include/hpdf_pages.h +128 -0
- data/ext/include/hpdf_streams.h +276 -0
- data/ext/include/hpdf_types.h +488 -0
- data/ext/include/hpdf_utils.h +161 -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 +147 -0
@@ -0,0 +1,161 @@
|
|
1
|
+
/*
|
2
|
+
* << Haru Free PDF Library 2.0.0 >> -- fpdf_utils.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_UTILS_H
|
16
|
+
#define _HPDF_UTILS_H
|
17
|
+
|
18
|
+
#include "hpdf_types.h"
|
19
|
+
|
20
|
+
#ifdef __cplusplus
|
21
|
+
extern "C" {
|
22
|
+
#endif /* __cplusplus */
|
23
|
+
|
24
|
+
HPDF_INT
|
25
|
+
HPDF_AToI (const char* s);
|
26
|
+
|
27
|
+
|
28
|
+
HPDF_DOUBLE
|
29
|
+
HPDF_AToF (const char* s);
|
30
|
+
|
31
|
+
|
32
|
+
char*
|
33
|
+
HPDF_IToA (char* s,
|
34
|
+
HPDF_INT32 val,
|
35
|
+
char* eptr);
|
36
|
+
|
37
|
+
|
38
|
+
char*
|
39
|
+
HPDF_IToA2 (char *s,
|
40
|
+
HPDF_UINT32 val,
|
41
|
+
HPDF_UINT len);
|
42
|
+
|
43
|
+
|
44
|
+
char*
|
45
|
+
HPDF_FToA (char *s,
|
46
|
+
HPDF_REAL val,
|
47
|
+
char *eptr);
|
48
|
+
|
49
|
+
|
50
|
+
HPDF_BYTE*
|
51
|
+
HPDF_MemCpy (HPDF_BYTE* out,
|
52
|
+
const HPDF_BYTE* in,
|
53
|
+
HPDF_UINT n);
|
54
|
+
|
55
|
+
|
56
|
+
HPDF_BYTE*
|
57
|
+
HPDF_StrCpy (char* out,
|
58
|
+
const char* in,
|
59
|
+
char* eptr);
|
60
|
+
|
61
|
+
|
62
|
+
HPDF_INT
|
63
|
+
HPDF_MemCmp (const HPDF_BYTE* s1,
|
64
|
+
const HPDF_BYTE* s2,
|
65
|
+
HPDF_UINT n);
|
66
|
+
|
67
|
+
|
68
|
+
HPDF_INT
|
69
|
+
HPDF_StrCmp (const char* s1,
|
70
|
+
const char* s2);
|
71
|
+
|
72
|
+
|
73
|
+
const char*
|
74
|
+
HPDF_StrStr (const char *s1,
|
75
|
+
const char *s2,
|
76
|
+
HPDF_UINT maxlen);
|
77
|
+
|
78
|
+
|
79
|
+
void*
|
80
|
+
HPDF_MemSet (void* s,
|
81
|
+
HPDF_BYTE c,
|
82
|
+
HPDF_UINT n);
|
83
|
+
|
84
|
+
|
85
|
+
HPDF_UINT
|
86
|
+
HPDF_StrLen (const char* s,
|
87
|
+
HPDF_INT maxlen);
|
88
|
+
|
89
|
+
|
90
|
+
HPDF_Box
|
91
|
+
HPDF_ToBox (HPDF_INT16 left,
|
92
|
+
HPDF_INT16 bottom,
|
93
|
+
HPDF_INT16 right,
|
94
|
+
HPDF_INT16 top);
|
95
|
+
|
96
|
+
|
97
|
+
HPDF_Point
|
98
|
+
HPDF_ToPoint (HPDF_INT16 x,
|
99
|
+
HPDF_INT16 y);
|
100
|
+
|
101
|
+
|
102
|
+
HPDF_Rect
|
103
|
+
HPDF_ToRect (HPDF_REAL left,
|
104
|
+
HPDF_REAL bottom,
|
105
|
+
HPDF_REAL right,
|
106
|
+
HPDF_REAL top);
|
107
|
+
|
108
|
+
|
109
|
+
void
|
110
|
+
HPDF_UInt16Swap (HPDF_UINT16 *value);
|
111
|
+
|
112
|
+
|
113
|
+
#ifdef __cplusplus
|
114
|
+
}
|
115
|
+
#endif /* __cplusplus */
|
116
|
+
|
117
|
+
#define HPDF_NEEDS_ESCAPE(c) (c < 0x21 || \
|
118
|
+
c > 0x7e || \
|
119
|
+
c == '\\' || \
|
120
|
+
c == '%' || \
|
121
|
+
c == '#' || \
|
122
|
+
c == '/' || \
|
123
|
+
c == '(' || \
|
124
|
+
c == ')' || \
|
125
|
+
c == '<' || \
|
126
|
+
c == '>' || \
|
127
|
+
c == '[' || \
|
128
|
+
c == ']' || \
|
129
|
+
c == '{' || \
|
130
|
+
c == '}' ) \
|
131
|
+
|
132
|
+
#define HPDF_IS_WHITE_SPACE(c) (c == 0x00 || \
|
133
|
+
c == 0x09 || \
|
134
|
+
c == 0x0A || \
|
135
|
+
c == 0x0C || \
|
136
|
+
c == 0x0D || \
|
137
|
+
c == 0x20 ) \
|
138
|
+
|
139
|
+
/*----------------------------------------------------------------------------*/
|
140
|
+
/*----- macros for debug -----------------------------------------------------*/
|
141
|
+
|
142
|
+
#ifdef HPDF_DEBUG
|
143
|
+
#ifndef HPDF_PTRACE_ON
|
144
|
+
#define HPDF_PTRACE_ON
|
145
|
+
#endif /* HPDF_PTRACE_ON */
|
146
|
+
#endif /* HPDF_DEBUG */
|
147
|
+
|
148
|
+
#ifdef HPDF_PTRACE_ON
|
149
|
+
#define HPDF_PTRACE(ARGS) HPDF_PRINTF ARGS
|
150
|
+
#else
|
151
|
+
#define HPDF_PTRACE(ARGS) /* do nothing */
|
152
|
+
#endif /* HPDF_PTRACE */
|
153
|
+
|
154
|
+
#ifdef HPDF_DEBUG
|
155
|
+
#define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) HPDF_PrintBinary(BUF, LEN, CAPTION)
|
156
|
+
#else
|
157
|
+
#define HPDF_PRINT_BINARY(BUF, LEN, CAPTION) /* do nothing */
|
158
|
+
#endif
|
159
|
+
|
160
|
+
#endif /* _HPDF_UTILS_H */
|
161
|
+
|
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)
|
data/tests/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)
|
data/tests/encryption.rb
ADDED
@@ -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)
|