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.
- 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
data/History
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
== version 2.0.8 2006.11.25
|
2
|
+
*fixed a problem of HPDF_Circle() which causes buffer overflow.
|
3
|
+
*added HPDF_Ellipse().
|
4
|
+
|
5
|
+
== version 2.0.7 2006.11.05
|
6
|
+
*fixed a bug of HPDF_Annotation_New() (the values of bottom and top are set
|
7
|
+
upside down).
|
8
|
+
*added HPDF_Page_GetCurrentPos2(), HPDF_Page_GetCurrentTextPos2() and
|
9
|
+
HPDF_Image_GetSize2().
|
10
|
+
|
11
|
+
== version 2.0.6 2006.10.16
|
12
|
+
*added opacity and blend-mode featurs.
|
13
|
+
*added slide-show functions (contributed by Adrian Nelson).
|
14
|
+
*added an interface for VB6 (contributed by Ko, Chi-Chih).
|
15
|
+
*fixed a bug that HPDF_MemStream_Rewrite() may cause segmentation fault.
|
16
|
+
*fixed a bug of error checking of HPDF_Page_Concat().
|
17
|
+
*fixed a bug of calculation for the position of text showing.
|
18
|
+
|
19
|
+
== version 2.0.5 2006.09.20
|
20
|
+
*fixed a bug that an image which loaded by HPDF_LoadRawImageFromFile() or
|
21
|
+
HPDF_LoadRawImageFromMem() is not compressed.
|
22
|
+
*added C# interface.
|
23
|
+
*added viewer-preference feature.
|
24
|
+
*fixed a bug that HPDF_SetPassword does not raise error when NULL string set
|
25
|
+
to owner-password.
|
26
|
+
*fixed a bug that causes program crash when using interlaced PNG images.
|
27
|
+
|
28
|
+
== version 2.0.4 2006.08.25
|
29
|
+
*fixed a bug of the TrueType font feature related to composit glyph.
|
30
|
+
|
31
|
+
== version 2.0.3 2006.08.20
|
32
|
+
*fixed a bug that HPDF_Page_TextRect() always returns
|
33
|
+
HPDF_PAGE_INSUFFICIENT_SPACE.
|
34
|
+
*added delayed loading function for a png image (HPDF_LoadPngImageFromFile2).
|
35
|
+
*change HPDF_SaveToStream function.
|
36
|
+
*correct hpdf_ttfontdef.c to avoid warning from a compiler.
|
37
|
+
|
38
|
+
== version 2.0.2
|
39
|
+
*modified HPDF_Page_ShowTextNextLine() to invoking HPDF_Page_MoveToNextLine()
|
40
|
+
if it is invoked with null or zero-length text.
|
41
|
+
*fixed a bug in which HPDF_Page_MeasureText() returns wrong value when using
|
42
|
+
CID fonts.
|
43
|
+
*changed the feature of HPDF_Page_MeasureText().
|
44
|
+
*added Japanese word wrap feature to HPDF_Page_MeasureText() and
|
45
|
+
HPDF_Page_TextRect().
|
46
|
+
*fixed typos of HPDF_PageLayout values.
|
47
|
+
*modified options of makefile for BCC32 to multi-thread.
|
48
|
+
rebuild libz.a, libpng.a for BCC32 with -WM option.
|
49
|
+
|
50
|
+
== version 2.0.1a 2006-08-03
|
51
|
+
*fixed a bug that HPDFPage::draw_image does not work correctly. (Ruby module
|
52
|
+
only.)
|
53
|
+
|
54
|
+
== version 2.0.1 2006-07-29
|
55
|
+
*fixed a bug that HPDF_TextRect() does not work correctly when using CID fonts.
|
56
|
+
*added HPDF_Font_GetAscent(), HPDF_Font_GetDescent(), HPDF_Font_GetXHeight(),
|
57
|
+
HPDF_Font_GetCapHeight().
|
data/License
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*
|
2
|
+
* License
|
3
|
+
*
|
4
|
+
Haru is distributed under the ZLIB/LIBPNG License. Because ZLIB/LIBPNG License
|
5
|
+
is one of the freest licenses, You can use Haru for various purposes.
|
6
|
+
|
7
|
+
The license of Haru is as follows.
|
8
|
+
|
9
|
+
Copyright (C) 1999-2006 Takeshi Kanno
|
10
|
+
This software is provided 'as-is', without any express or implied warranty.
|
11
|
+
|
12
|
+
In no event will the authors be held liable for any damages arising from the
|
13
|
+
use of this software.
|
14
|
+
|
15
|
+
Permission is granted to anyone to use this software for any purpose,including
|
16
|
+
commercial applications, and to alter it and redistribute it freely, subject
|
17
|
+
to the following restrictions:
|
18
|
+
|
19
|
+
1. The origin of this software must not be misrepresented; you must not claim
|
20
|
+
that you wrote the original software. If you use this software in a
|
21
|
+
product, an acknowledgment in the product documentation would be
|
22
|
+
appreciated but is not required.
|
23
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
24
|
+
misrepresented as being the original software.
|
25
|
+
3. This notice may not be removed or altered from any source distribution.
|
data/README
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
===============================================================================
|
2
|
+
# Haru Free PDF Library Version 2.0.8 - Nov 25, 2006
|
3
|
+
|
4
|
+
This gem has been packaged by Emmanuel Oga, EmmanuelOga.blogspot.com
|
5
|
+
|
6
|
+
I followed the instructions in the libharu_2_x_x.tar.gz package:
|
7
|
+
|
8
|
+
1) Build Haru as a static library.
|
9
|
+
|
10
|
+
NOTE:
|
11
|
+
When you build haru for creating ruby extension library on linux
|
12
|
+
platforms, run configure script with following command.
|
13
|
+
|
14
|
+
./configure --cflags=-fPIC
|
15
|
+
|
16
|
+
2) Change directory to "libharu-2.X.X/if/ruby" and run extconf.rb.
|
17
|
+
|
18
|
+
ruby extconf.rb
|
19
|
+
|
20
|
+
3) Then invoke "make install" command.
|
21
|
+
|
22
|
+
make install
|
23
|
+
|
24
|
+
That's all!!! I only "gemified" the code and included the samples.
|
25
|
+
|
26
|
+
WARNING! TO USE THIS GEM on linux you need proper build tools (complete gcc package),
|
27
|
+
libpng and zlib. I had to make some research to find these for my ubuntu feisty
|
28
|
+
o.s.
|
29
|
+
|
30
|
+
If you are using ubuntu (or maybe debian or other linux with apt support)
|
31
|
+
|
32
|
+
"sudo apt-get install build-essential"
|
33
|
+
|
34
|
+
should do the trick for the build environment.
|
35
|
+
|
36
|
+
For zlib and libpng, you could install the program "apt-file" (sudo apt-get install apt-file)
|
37
|
+
and search the dependencies with it.
|
38
|
+
|
39
|
+
"apt-file search png.h"
|
40
|
+
"apt-file search zlib.h"
|
41
|
+
|
42
|
+
Choose one of the listed packages and install it with apt-get.
|
43
|
+
Then you should have no problem installing the gem.
|
44
|
+
|
45
|
+
Original readme follows:
|
46
|
+
|
47
|
+
===============================================================================
|
48
|
+
|
49
|
+
# Haru Free PDF Library Version 2.0.8 - Nov 25, 2006
|
50
|
+
#
|
51
|
+
# URL http://libharu.sourceforge.net/
|
52
|
+
#
|
53
|
+
# Copyright 2000-2006 (c) Takeshi Kanno
|
54
|
+
#
|
55
|
+
|
56
|
+
See INSTALL for instructions on how to install libpng.
|
57
|
+
|
58
|
+
*
|
59
|
+
* What is Haru Free PDF Library?
|
60
|
+
*
|
61
|
+
Haru is a free, cross platform, open-sourced software library for generating
|
62
|
+
PDF. It supports the following features.
|
63
|
+
|
64
|
+
1. Generating PDF files with lines, text, images.
|
65
|
+
2. Outline, text annotation, link annotation.
|
66
|
+
3. Compressing document with deflate-decode.
|
67
|
+
4. Embedding PNG, Jpeg images.
|
68
|
+
5. Embedding Type1 font and TrueType font.
|
69
|
+
6. Creating encrypted PDF files.
|
70
|
+
7. Using various character set (ISO8859-1~16, MSCP1250~8, KOI-8R).
|
71
|
+
8. Supporting CJK fonts and encodings.
|
72
|
+
|
73
|
+
You can add the feature of PDF creation by using Haru without understanding
|
74
|
+
complicated internal structure of PDF.
|
75
|
+
|
76
|
+
*
|
77
|
+
* The differences from the previous version
|
78
|
+
*
|
79
|
+
|
80
|
+
The biggest differences are that all code is written in C.
|
81
|
+
To our regret, because internal structures changed greatly, The API is not
|
82
|
+
compatible with previous version.
|
83
|
+
|
84
|
+
However, the new-version has the following advantages compared with the
|
85
|
+
previous version.
|
86
|
+
|
87
|
+
1. Supported shared-library build.
|
88
|
+
A new-version library is able to be built as shared-library.
|
89
|
+
2. The performance has been greatly improved.
|
90
|
+
A new-version library is about 4-15 times faster than a previous version.
|
91
|
+
3. Supported more features.
|
92
|
+
TrueType font, 128 bit encryption, arc function, and so on.
|
93
|
+
|
94
|
+
*
|
95
|
+
* Supporting platforms
|
96
|
+
*
|
97
|
+
Haru is written in ANSI-C and should compile easily with any compliant C
|
98
|
+
compiler.
|
99
|
+
I inspected Haru in the following environment and make files for these
|
100
|
+
environments are included in a package.
|
101
|
+
|
102
|
+
1. Cygwin + GCC (Microsoft Windows)
|
103
|
+
2. Cygwin + MinGW (Microsoft Windows)
|
104
|
+
3. MSYS + MinGW (Microsoft Windows)
|
105
|
+
3. Microsoft VC++ (Microsoft Windows)
|
106
|
+
4. Borland C++ (Microsoft Windows)
|
107
|
+
5. GCC (Linux, FreeBSD, NetBSD, Solaris...)
|
108
|
+
|
109
|
+
Also on platforms except the above, it is easy to build HARU. If you success to build HARU on other platforms, please send makefile to me.
|
110
|
+
In addition, ZLIB and PNGLIB are required when you want to use the features of
|
111
|
+
compression and embedding PNG images. (In the case of Windows, static library
|
112
|
+
files for several compilers are included in the package for WIndows. In the
|
113
|
+
case of most of UNIX, these libraries are usually installed.)
|
114
|
+
|
115
|
+
*
|
116
|
+
* Available development environment
|
117
|
+
*
|
118
|
+
Haru can work as both static-library (.a, .lib) and shared-library (.so, .dll).
|
119
|
+
When you use it as static-library, It can be used by C and a C++.
|
120
|
+
But when you use it as shared-library, it can be used by many development
|
121
|
+
languages which support shared library.
|
122
|
+
So far, Haru provides bindings for Ruby, Delphi/Free Pascal and C#.
|
123
|
+
|
124
|
+
If you write bindings for other programing languages, please notice me!
|
125
|
+
|
126
|
+
*
|
127
|
+
* Runtime environment of programs using Haru
|
128
|
+
*
|
129
|
+
1. static-library
|
130
|
+
No runtime files are required.
|
131
|
+
|
132
|
+
2. shared-library
|
133
|
+
In Windows, you have to distribute libhpdf.dll with a program. In UNIX you
|
134
|
+
have to distribute libhpdf.so* with a program.
|
135
|
+
|
136
|
+
NOTE:
|
137
|
+
In the UNIX environment, there are the cases that libz.so, libpng.so.x are
|
138
|
+
necessary. About this, please refer to the documentation of PNGLIB and ZLIB.
|
139
|
+
|
140
|
+
*
|
141
|
+
* Acknowledgment
|
142
|
+
*
|
143
|
+
1. Information-technology Promotion Agency(IPA)
|
144
|
+
The development of Haru has been supported by Exploratory Software Project
|
145
|
+
of Information-technology Promotion Agency(IPA), Japan.
|
146
|
+
|
147
|
+
2. All users of libHaru.
|
148
|
+
We wish to thank all users of Haru.
|
149
|
+
In particular, we thank Thomas Nimstad, LeslieM, Par Hogberg, adenelson,
|
150
|
+
Riccardo Cohen, sea_sbs, Andrew.
|
151
|
+
They gave me very useful advices.
|
152
|
+
|
153
|
+
3. Sourceforge.net
|
154
|
+
We would like to thank sourceForge.net for project hosting.
|
155
|
+
|
156
|
+
4. Adobe Systems Inc.
|
157
|
+
We thank Adobe Systems Inc. for publishing PDF specification.
|
158
|
+
|
159
|
+
|
160
|
+
TODO - todo for libharu
|
161
|
+
|
162
|
+
* Vertical writing support of HPDF_TextRect()
|
163
|
+
* Correct a code which uses implicit type conversion and causes warnings.
|
164
|
+
* Form desiner.
|
165
|
+
|
@@ -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
|
+
require 'rubygems'
|
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/examples/demo.rb
ADDED
@@ -0,0 +1,92 @@
|
|
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 'rubygems'
|
15
|
+
require "hpdf"
|
16
|
+
|
17
|
+
if ARGV.empty?
|
18
|
+
line = 'Ruby Rocks'
|
19
|
+
else
|
20
|
+
line = ARGV.join(" ")
|
21
|
+
end
|
22
|
+
|
23
|
+
pdf = HPDFDoc.new
|
24
|
+
|
25
|
+
page = pdf.add_page
|
26
|
+
|
27
|
+
x = 578
|
28
|
+
r1 = 25
|
29
|
+
|
30
|
+
40.step(1, -3) do |xw|
|
31
|
+
tone = 1.0 - (xw / 40.0) * 0.2
|
32
|
+
|
33
|
+
page.set_line_width(xw.to_f)
|
34
|
+
page.set_rgb_stroke(tone, 1.0, tone)
|
35
|
+
page.circle(50.0, 750.0, r1.to_f)
|
36
|
+
page.stroke
|
37
|
+
r1 += xw
|
38
|
+
end
|
39
|
+
|
40
|
+
40.step(1, -3) do |xw|
|
41
|
+
tone = 1.0 - (xw / 40.0) * 0.2
|
42
|
+
|
43
|
+
page.set_line_width(xw.to_f)
|
44
|
+
page.set_rgb_stroke(tone, tone, 1.0)
|
45
|
+
page.move_to(x.to_f, 0.0)
|
46
|
+
page.line_to(x.to_f, 842.0)
|
47
|
+
page.stroke
|
48
|
+
x = (x - xw - 2)
|
49
|
+
end
|
50
|
+
|
51
|
+
page.set_rgb_stroke(0.0, 0.0, 0.0)
|
52
|
+
page.set_line_width(1.0)
|
53
|
+
page.rectangle(20.0, 20.0, 558.0, 802.0)
|
54
|
+
page.stroke
|
55
|
+
|
56
|
+
font = pdf.get_font("Helvetica", nil)
|
57
|
+
bbox = font.get_bbox
|
58
|
+
|
59
|
+
y = 800
|
60
|
+
50.step(5, -5) do |size|
|
61
|
+
height = (bbox[3] - bbox[1]) / 1000 * size
|
62
|
+
y = y - height
|
63
|
+
|
64
|
+
page.begin_text
|
65
|
+
page.set_font_and_size(font, size.to_f)
|
66
|
+
page.text_out(30.0, y.to_f, line)
|
67
|
+
page.end_text
|
68
|
+
end
|
69
|
+
|
70
|
+
(0...360).step(20) do |angle|
|
71
|
+
page.set_rgb_fill(rand, rand, rand)
|
72
|
+
|
73
|
+
page.begin_text
|
74
|
+
rad = angle / 180.0 * 3.141592
|
75
|
+
page.set_font_and_size(font, 20.0)
|
76
|
+
page.set_text_matrix(Math.cos(rad),
|
77
|
+
Math.sin(rad),
|
78
|
+
-Math.sin(rad),
|
79
|
+
Math.cos(rad),
|
80
|
+
300 + Math.cos(rad) * 40,
|
81
|
+
300 + Math.sin(rad) * 40)
|
82
|
+
page.show_text(line)
|
83
|
+
page.end_text
|
84
|
+
end
|
85
|
+
|
86
|
+
if $demo_output_filename
|
87
|
+
file_name= $demo_output_filename
|
88
|
+
else
|
89
|
+
file_name= $0 + ".pdf"
|
90
|
+
end
|
91
|
+
|
92
|
+
pdf.save_to_file(file_name)
|
@@ -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
|
+
require 'rubygems'
|
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)
|