ypdf-writer 1.3.2
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.
- checksums.yaml +7 -0
- data/ChangeLog +134 -0
- data/LICENCE +131 -0
- data/bin/techbook +24 -0
- data/demo/chunkybacon.rb +40 -0
- data/demo/code.rb +71 -0
- data/demo/colornames.rb +47 -0
- data/demo/demo.rb +73 -0
- data/demo/gettysburg.rb +66 -0
- data/demo/hello.rb +26 -0
- data/demo/individual-i.rb +89 -0
- data/demo/pac.rb +70 -0
- data/demo/qr-language.rb +580 -0
- data/demo/qr-library.rb +380 -0
- data/images/bluesmoke.jpg +0 -0
- data/images/chunkybacon.jpg +0 -0
- data/images/chunkybacon.png +0 -0
- data/lib/pdf/charts.rb +13 -0
- data/lib/pdf/charts/stddev.rb +431 -0
- data/lib/pdf/core_ext/mutex.rb +12 -0
- data/lib/pdf/math.rb +108 -0
- data/lib/pdf/quickref.rb +333 -0
- data/lib/pdf/simpletable.rb +952 -0
- data/lib/pdf/techbook.rb +907 -0
- data/lib/pdf/writer.rb +2760 -0
- data/lib/pdf/writer/arc4.rb +63 -0
- data/lib/pdf/writer/fontmetrics.rb +203 -0
- data/lib/pdf/writer/fonts/Courier-Bold.afm +342 -0
- data/lib/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
- data/lib/pdf/writer/fonts/Courier-Oblique.afm +342 -0
- data/lib/pdf/writer/fonts/Courier.afm +342 -0
- data/lib/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
- data/lib/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/lib/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
- data/lib/pdf/writer/fonts/Helvetica.afm +3051 -0
- data/lib/pdf/writer/fonts/MustRead.html +19 -0
- data/lib/pdf/writer/fonts/Symbol.afm +213 -0
- data/lib/pdf/writer/fonts/Times-Bold.afm +2588 -0
- data/lib/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
- data/lib/pdf/writer/fonts/Times-Italic.afm +2667 -0
- data/lib/pdf/writer/fonts/Times-Roman.afm +2419 -0
- data/lib/pdf/writer/fonts/ZapfDingbats.afm +225 -0
- data/lib/pdf/writer/graphics.rb +813 -0
- data/lib/pdf/writer/graphics/imageinfo.rb +366 -0
- data/lib/pdf/writer/lang.rb +43 -0
- data/lib/pdf/writer/lang/en.rb +99 -0
- data/lib/pdf/writer/object.rb +23 -0
- data/lib/pdf/writer/object/action.rb +35 -0
- data/lib/pdf/writer/object/annotation.rb +42 -0
- data/lib/pdf/writer/object/catalog.rb +39 -0
- data/lib/pdf/writer/object/contents.rb +70 -0
- data/lib/pdf/writer/object/destination.rb +40 -0
- data/lib/pdf/writer/object/encryption.rb +53 -0
- data/lib/pdf/writer/object/font.rb +72 -0
- data/lib/pdf/writer/object/fontdescriptor.rb +34 -0
- data/lib/pdf/writer/object/fontencoding.rb +40 -0
- data/lib/pdf/writer/object/image.rb +305 -0
- data/lib/pdf/writer/object/info.rb +51 -0
- data/lib/pdf/writer/object/outline.rb +30 -0
- data/lib/pdf/writer/object/outlines.rb +30 -0
- data/lib/pdf/writer/object/page.rb +195 -0
- data/lib/pdf/writer/object/pages.rb +115 -0
- data/lib/pdf/writer/object/procset.rb +46 -0
- data/lib/pdf/writer/object/viewerpreferences.rb +74 -0
- data/lib/pdf/writer/ohash.rb +58 -0
- data/lib/pdf/writer/oreader.rb +25 -0
- data/lib/pdf/writer/state.rb +48 -0
- data/lib/pdf/writer/strokestyle.rb +138 -0
- data/manual.pwd +5965 -0
- data/readme.md +36 -0
- metadata +151 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6ff56129757a80fa66031f67959dd7e311642be2
|
|
4
|
+
data.tar.gz: d2d969306cd83075f899badfd7144c1f68f46bbd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0e3feedf6dfab20b90d46f590ca740fcadeb68a24e90db718c2da213c129d153dd2e1f1bbadf69bb74e57c728d358dc40c8154d367f5df45b710999a686c835d
|
|
7
|
+
data.tar.gz: 53569a3943757556152f075023c6e700cc808265afa193beb0d20f2e88b7f53e5f71d84e544ff07d00c040e0256769625b1584895ebd9dbc9a0b8eda8a103bc2
|
data/ChangeLog
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
= PDF::Writer Change Log
|
|
2
|
+
|
|
3
|
+
== PDF::Writer 1.3.2: May 10, 2016
|
|
4
|
+
* More Ruby 2.3 compatibility:
|
|
5
|
+
o Use bundler/gem_tasks to create the gem
|
|
6
|
+
o Only for internal ywesee usage
|
|
7
|
+
|
|
8
|
+
== PDF::Writer 1.3.1: November 26, 2013
|
|
9
|
+
* More Ruby 2.0 compatibility:
|
|
10
|
+
o Changed encodings from ISO-8859-1 to ASCII-8BIT for binary strings.
|
|
11
|
+
o Fixed problems in ImageInfo with binary strings.
|
|
12
|
+
o Fixed problem using add_text with embedded links when not using encryption.
|
|
13
|
+
o Changed Mutex marshalling monkeypatch to actually dump and return a new mutex.
|
|
14
|
+
This is required for Transaction::Simple support, which is used in SimpleTable.
|
|
15
|
+
o The add_text method now tries to handle character encodings.
|
|
16
|
+
o Added some tests.
|
|
17
|
+
|
|
18
|
+
== PDF::Writer 1.3.0: August 16, 2013
|
|
19
|
+
* Ruby 2.0 compatibility.
|
|
20
|
+
o ImageInfo fixes encoding issue
|
|
21
|
+
o Writer fixes enumeration of String
|
|
22
|
+
o Fixed computation of font-width calculations
|
|
23
|
+
|
|
24
|
+
== PDF::Writer 1.2.1: May 13, 2009
|
|
25
|
+
* Ruby 1.9 compatibility.
|
|
26
|
+
|
|
27
|
+
== PDF::Writer 1.1.3: September 9, 2005
|
|
28
|
+
* Fixed #2356 submitted by Matthew Thill. Margins set by the various margins
|
|
29
|
+
methods would behave incorrectly.
|
|
30
|
+
|
|
31
|
+
== PDF::Writer 1.1.2: August 25, 2005
|
|
32
|
+
* Thomas Gantner <thomas.gantner@gmx.net> found a problem with the
|
|
33
|
+
interpretation of the placement of page numbers and provided a patch.
|
|
34
|
+
Thanks!
|
|
35
|
+
* Thomas also reported a problem with an inability to place page numbering on
|
|
36
|
+
the first page of a document, as well as strange results from not providing
|
|
37
|
+
a starting page number. This has been fixed. Also reported as #2204.
|
|
38
|
+
* Modified PDF::Writer requirements to require color-tools version 1.3.0 or
|
|
39
|
+
later. This necessitates that Color constants be changed to Color::RGB
|
|
40
|
+
constants.
|
|
41
|
+
* Updated supporting library documentation to include information on
|
|
42
|
+
color-tools version 1.3.
|
|
43
|
+
* Fixed a bug with Graphics#transform_matrix truncating one of the transform
|
|
44
|
+
parameters.
|
|
45
|
+
* Applied a fix to PDF::SimpleTable submitted by Mike Leddy in #2129 on the
|
|
46
|
+
RubyForge tracker.
|
|
47
|
+
* Applied a partial fix for PNG with index-transparency provided by Marc
|
|
48
|
+
Vleugels in #2245 on the RubyForge tracker. NOTE: This does not solve the
|
|
49
|
+
transparency problem; at this point, PDF::Writer cannot be said to support
|
|
50
|
+
PNGs with transparency. This will be fixed in a later version of
|
|
51
|
+
PDF::Writer.
|
|
52
|
+
|
|
53
|
+
== PDF::Writer 1.1.1: July 1, 2005
|
|
54
|
+
* Fixed the packaging process; the .tar.gz files will no longer corrupt the
|
|
55
|
+
images.
|
|
56
|
+
* Added the images and the manual (both raw and generated) to the demo
|
|
57
|
+
package.
|
|
58
|
+
|
|
59
|
+
== PDF::Writer 1.1.0: June 29, 2005
|
|
60
|
+
NOTE: The first two changes are INCOMPATIBLE with previous versions of
|
|
61
|
+
PDF::Writer. If you find that your text is showing up at odd angles, negate
|
|
62
|
+
the value. That is, if you have 90 as your angle, use -90 (or 270) as your
|
|
63
|
+
angle and it will work like it used to.
|
|
64
|
+
|
|
65
|
+
* Axis transformations in PDF::Writer::Graphics have been fixed.
|
|
66
|
+
* Text axis transformation in PDF::Writer#add_text has been fixed.
|
|
67
|
+
* Changed #text_width and #text_line_width so that the text value is the
|
|
68
|
+
first parameter and the size parameter is second, and is optional. The code
|
|
69
|
+
warns about it now, but it will break in PDF::Writer 2.0.
|
|
70
|
+
* Changed #add_text and #add_text_wrap so that the text parameter is before
|
|
71
|
+
the now-optional size parameter. The code warns about it now, but it will
|
|
72
|
+
break in PDF::Writer 2.0.
|
|
73
|
+
* Added #transform_matrix.
|
|
74
|
+
* Fixed compression. NOTE: Compression must be set early in the documentation
|
|
75
|
+
process, or only some items will be compressed in the document. The various
|
|
76
|
+
#save_as methods have been changed to reflect this fact.
|
|
77
|
+
* Enabled the placement of encoding differences dictionaries in the resulting
|
|
78
|
+
PDF document. This change should be considered experimental.
|
|
79
|
+
* Added TTF licence checking. The embedding of a file not licenced for
|
|
80
|
+
inclusion in a document will continue, but a warning will be output to
|
|
81
|
+
standard error. This code has been gakked from FPDF (http://www.fpdf.org).
|
|
82
|
+
* Properly supporting symbolic font flags now.
|
|
83
|
+
* Added support and documentation for a separately downloadable demo package.
|
|
84
|
+
* Expanded the installation documentation.
|
|
85
|
+
* Added the ability to make images clickable links with any of the three
|
|
86
|
+
image insertion methods.
|
|
87
|
+
|
|
88
|
+
== PDF::Writer 1.0.1: June 13, 2005
|
|
89
|
+
* Fixed a few minor gem issues.
|
|
90
|
+
* Renamed bin/manual to bin/techbook.
|
|
91
|
+
* Fixed the manual.pwd locator for the default install.
|
|
92
|
+
|
|
93
|
+
== PDF::Writer 1.0.0: June 12, 2005
|
|
94
|
+
* Integrated ezwriter.rb functionality with writer.rb.
|
|
95
|
+
* Factored out some functionality into modules and classes.
|
|
96
|
+
* Added CMYK colour support to JPEG images.
|
|
97
|
+
* Uses Color::CMYK (from color-utils) to provide CMYK support to drawing
|
|
98
|
+
capabilities.
|
|
99
|
+
* Simplified the image API significantly.
|
|
100
|
+
* Modified image support to properly handle full image flipping.
|
|
101
|
+
* Fixed several multi-column issues.
|
|
102
|
+
* Fixed a bug where new pages automatically started by overflowing text may
|
|
103
|
+
have resulted in writing the first line of text above the top margin. This
|
|
104
|
+
may need further testing and probably causes problems with column handling.
|
|
105
|
+
* Fixed some page numbering issues.
|
|
106
|
+
* Added several demos, including Ruby Quick Reference Sheets.
|
|
107
|
+
* Scrubbed the API.
|
|
108
|
+
* Updated the documentation.
|
|
109
|
+
* Changed installer to setup.rb 3.3.1-modified.
|
|
110
|
+
* Applied an image resize patch; the image will be resized manually before
|
|
111
|
+
checking to see if a new page is required. Thanks to Leslie Hensley.
|
|
112
|
+
* Fixed a bug where entities would generate the width specified for the
|
|
113
|
+
component characters, not the represented characters.
|
|
114
|
+
* Fixed a performance bug. Thanks again to Leslie Hensley.
|
|
115
|
+
|
|
116
|
+
== PDF::Writer 0.1.2: CVS only
|
|
117
|
+
* Fixed a problem with the improper reading of character numbers from .afm
|
|
118
|
+
files that are not default files. Other font issues remain but will be fixed
|
|
119
|
+
at a later date.
|
|
120
|
+
|
|
121
|
+
== PDF::Writer 0.1.0: September, 2003
|
|
122
|
+
* Initial technology preview.
|
|
123
|
+
|
|
124
|
+
#--
|
|
125
|
+
# PDF::Writer for Ruby.
|
|
126
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
|
127
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
|
128
|
+
#
|
|
129
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
|
130
|
+
# for full licensing information.
|
|
131
|
+
#
|
|
132
|
+
# $Id$
|
|
133
|
+
#++
|
|
134
|
+
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/LICENCE
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
= PDF::Writer for Ruby
|
|
2
|
+
Homepage:: http://rubyforge.org/projects/ruby-pdf/
|
|
3
|
+
Copyright:: Copyright � 2003�2005 Austin Ziegler.
|
|
4
|
+
Summary:: MIT-style
|
|
5
|
+
|
|
6
|
+
This project had a change of maintainers in November, 2007.
|
|
7
|
+
New developments are now copyrighted by Gregory Brown and Michael Milner,
|
|
8
|
+
unless otherwise noted.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
* The names of its contributors may not be used to endorse or promote
|
|
20
|
+
products derived from this software without specific prior written
|
|
21
|
+
permission.
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in
|
|
24
|
+
all copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
== Works Included Under Other Licences
|
|
35
|
+
=== pdf/writer/graphics/imageinfo.rb
|
|
36
|
+
PDF::Writer includes a derivative of Keisuke Minami's ImageSize library,
|
|
37
|
+
which can be found at rubycgi[http://www.rubycgi.org/tools/index.en.htm].
|
|
38
|
+
This work�and only this or other named works�may be treated as under the Ruby
|
|
39
|
+
licensing scheme (GPL 2 or later, Ruby's licence) as well as the overall
|
|
40
|
+
PDF::Writer licence.
|
|
41
|
+
|
|
42
|
+
=== Ruby Quick Reference Sheets
|
|
43
|
+
PDF::Writer has demo programs that will create Quick Reference cards for
|
|
44
|
+
Ruby. The content and output of these programs is copyright 2003�2005 Ryan
|
|
45
|
+
Davis and is licensed under the Creative Commons
|
|
46
|
+
Attribution-NonCommercial-ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/]
|
|
47
|
+
licence.
|
|
48
|
+
|
|
49
|
+
=== Images from "Why's (Poignant) Guide to Ruby"
|
|
50
|
+
One of the demo programs uses images originally from "Why's (Poignant) Guide
|
|
51
|
+
to Ruby"[http://poignantguide.net/ruby], with permission. These immages are
|
|
52
|
+
released under the Creative Commons
|
|
53
|
+
Attributions ShareAlike[http://creativecommons.org/licenses/by-sa/2.0/]
|
|
54
|
+
licence.
|
|
55
|
+
|
|
56
|
+
=== Adobe PostScript AFM Files
|
|
57
|
+
pdf/writer/fonts/MustRead.html and the 14 PostScript(R) AFM files it
|
|
58
|
+
accompanies may be used, copied, and distributed for any purpose and without
|
|
59
|
+
charge, with or without modification, provided that all copyright notices are
|
|
60
|
+
retained; that the AFM files are not distributed without this file; that all
|
|
61
|
+
modifications to this file or any of the AFM files are prominently noted in
|
|
62
|
+
the modified file(s); and that this paragraph is not modified. Adobe Systems
|
|
63
|
+
has no responsibility or obligation to support the use of the AFM files.
|
|
64
|
+
|
|
65
|
+
== Other Credits
|
|
66
|
+
=== PDF::Writer
|
|
67
|
+
PDF::Writer is based originally on the R & OS PDF class for
|
|
68
|
+
PHP[http://www.ros.co.nz/pdf/], which is released as public domain.
|
|
69
|
+
|
|
70
|
+
=== Standard Deviation Chart
|
|
71
|
+
The standard deviation chart (pdf/charts/stddev.rb) class is based on
|
|
72
|
+
work by Cris Ewing[mailto:cewing@u.washington.edu] of the University of
|
|
73
|
+
Washington School of Medicine, originally created for the R & OS PDF class
|
|
74
|
+
for PHP. He has graciously donated the code for PDF::Writer for Ruby.
|
|
75
|
+
|
|
76
|
+
=== bluesmoke.jpg
|
|
77
|
+
The logo image for PDF::Writer, bluesmoke.jpg, is modified from a picture
|
|
78
|
+
taken by Matthew "TheSaint" Bowden[mailto:matthewbowden@gmail.com] and is
|
|
79
|
+
available on the stock.xchng(R) at
|
|
80
|
+
<http://www.sxc.hu/browse.phtml?f=view&id=275430>. Many thanks to Matthew for
|
|
81
|
+
the use of this image.
|
|
82
|
+
|
|
83
|
+
== Patents Covering the Adobe PDF Format
|
|
84
|
+
=== ADOBE PATENTS
|
|
85
|
+
This software is based on Adobe's PDF Reference, Third Edition, version 1.6.
|
|
86
|
+
There may be limitations on the use of this library based on patent
|
|
87
|
+
restrictions from Adobe. See bewlow for more information.
|
|
88
|
+
|
|
89
|
+
=== UNISYS LZW PATENT
|
|
90
|
+
This software does not fully conform to the Adobe PDF specification because
|
|
91
|
+
no support for LZW is included in this software. At the time of original
|
|
92
|
+
development of this software (2003), the Unisys LZW patent was still in
|
|
93
|
+
effect outside of the United States. This will be modified in a future
|
|
94
|
+
version of this software.
|
|
95
|
+
|
|
96
|
+
== Patent Clarification Notice: Reading and Writing PDF Files
|
|
97
|
+
Adobe has a number of patents covering technology that is disclosed in the
|
|
98
|
+
Portable Document Format (PDF) Specification, version 1.6 and later, as
|
|
99
|
+
documented in PDF Reference and associated Technical Notes (the
|
|
100
|
+
"Specification". Adobe desires to promote the use of PDF for information
|
|
101
|
+
interchange among diverse products and applications.
|
|
102
|
+
|
|
103
|
+
Accordingly, the following patents are licensed on a royalty-free, non-
|
|
104
|
+
exclusive basis for the term of each patent and for the sole purpose of
|
|
105
|
+
developing software that produces, consumes, and interprets PDF files that
|
|
106
|
+
are compliant with the Specification:
|
|
107
|
+
|
|
108
|
+
U.S. Patent Numbers: 5,634,064; 5,737,599; 5,781,785; 5,819,301; 6,028,583;
|
|
109
|
+
6,289,364; 6,421,460
|
|
110
|
+
|
|
111
|
+
In addition, the following patent is licensed on a royalty-free, non-
|
|
112
|
+
exclusive basis for its term and for the sole purpose of developing software
|
|
113
|
+
that produces PDF files that are compliant with the Specification
|
|
114
|
+
(specifically excluding, however, software that consumes and/or interprets
|
|
115
|
+
PDF files):
|
|
116
|
+
|
|
117
|
+
U.S. Patent Numbers: 5,860,074
|
|
118
|
+
|
|
119
|
+
The above licenses are limited to only those rights required to implement the
|
|
120
|
+
Specification and no others. That is to say, Adobe grants only those rights
|
|
121
|
+
in the above patent(s) necessarily practiced to implement the Specification,
|
|
122
|
+
and does not grant any rights not required to implement the Specification.
|
|
123
|
+
The licenses do not grant the right to practice any patent covering other
|
|
124
|
+
technologies, such as implementation techniques that are not explicitly
|
|
125
|
+
disclosed in the Specification, nor does it allow the use of any patented
|
|
126
|
+
feature for any purpose other than as set forth in the applicable license
|
|
127
|
+
grant. Adobe has other patents in various fields, none of which are hereby
|
|
128
|
+
licensed.
|
|
129
|
+
|
|
130
|
+
$Id$
|
|
131
|
+
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/bin/techbook
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#! /usr/bin/env ruby
|
|
2
|
+
#--
|
|
3
|
+
# PDF::Writer for Ruby.
|
|
4
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
|
5
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
|
8
|
+
# for full licensing information.
|
|
9
|
+
#
|
|
10
|
+
# $Id$
|
|
11
|
+
#++
|
|
12
|
+
begin
|
|
13
|
+
require 'pdf/techbook'
|
|
14
|
+
rescue LoadError => le
|
|
15
|
+
if le.message =~ %r{pdf/techbook$}
|
|
16
|
+
root = File.dirname(File.dirname(File.expand_path(__FILE__)))
|
|
17
|
+
$LOAD_PATH.unshift(File.join(root, "lib"))
|
|
18
|
+
require 'pdf/techbook'
|
|
19
|
+
else
|
|
20
|
+
raise
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
PDF::TechBook.run(ARGV)
|
data/demo/chunkybacon.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# PDF::Writer for Ruby.
|
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
|
7
|
+
# for full licensing information.
|
|
8
|
+
#
|
|
9
|
+
# Images used in this demo are copyright 2004 - 2005 Why the Lucky Stiff
|
|
10
|
+
# and are from "Why's (Poignant) Guide to Ruby" at
|
|
11
|
+
# <http://poignantguide.net/ruby> with permission.
|
|
12
|
+
#
|
|
13
|
+
# $Id$
|
|
14
|
+
#++
|
|
15
|
+
|
|
16
|
+
# support running from within Textmate
|
|
17
|
+
Dir.chdir(File.dirname(__FILE__))
|
|
18
|
+
|
|
19
|
+
begin
|
|
20
|
+
require 'pdf/writer'
|
|
21
|
+
rescue LoadError => le
|
|
22
|
+
if le.message =~ %r{pdf/writer$}
|
|
23
|
+
$LOAD_PATH.unshift("../lib")
|
|
24
|
+
require 'pdf/writer'
|
|
25
|
+
else
|
|
26
|
+
raise
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
pdf = PDF::Writer.new
|
|
31
|
+
pdf.select_font "Times-Roman"
|
|
32
|
+
pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
|
|
33
|
+
|
|
34
|
+
i0 = pdf.image "../images/chunkybacon.jpg", :resize => 0.75
|
|
35
|
+
i1 = pdf.image "../images/chunkybacon.png", :justification => :center, :resize => 0.75
|
|
36
|
+
pdf.image i0, :justification => :right, :resize => 0.75
|
|
37
|
+
|
|
38
|
+
pdf.text "Chunky Bacon!!", :font_size => 72, :justification => :center
|
|
39
|
+
|
|
40
|
+
pdf.save_as("chunkybacon.pdf")
|
data/demo/code.rb
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# PDF::Writer for Ruby.
|
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
|
7
|
+
# for full licensing information.
|
|
8
|
+
#
|
|
9
|
+
# The code in this file is highly experimental and is not generally ready
|
|
10
|
+
# for use. I can't figure out why the stuff *after* is so far to the right.
|
|
11
|
+
# I'll need to play with the X position some to get it right. This will NOT
|
|
12
|
+
# make it into the 1.0 release. Maybe 1.1 or 1.2.
|
|
13
|
+
#
|
|
14
|
+
# $Id$
|
|
15
|
+
#++
|
|
16
|
+
begin
|
|
17
|
+
require 'pdf/writer'
|
|
18
|
+
rescue LoadError => le
|
|
19
|
+
if le.message =~ %r{pdf/writer$}
|
|
20
|
+
$LOAD_PATH.unshift("../lib")
|
|
21
|
+
require 'pdf/writer'
|
|
22
|
+
else
|
|
23
|
+
raise
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
pdf = PDF::Writer.new
|
|
28
|
+
pdf.select_font "Times-Roman"
|
|
29
|
+
|
|
30
|
+
class TagCodeFont
|
|
31
|
+
FONT_NAME = "Courier"
|
|
32
|
+
FONT_ENCODING = nil
|
|
33
|
+
FONT_SIZE_DIFF = 0.9
|
|
34
|
+
|
|
35
|
+
class << self
|
|
36
|
+
attr_accessor :font_name
|
|
37
|
+
|
|
38
|
+
def [](pdf, info)
|
|
39
|
+
@font_name ||= FONT_NAME
|
|
40
|
+
@font_encoding ||= FONT_ENCODING
|
|
41
|
+
|
|
42
|
+
case info[:status]
|
|
43
|
+
when :start, :start_line
|
|
44
|
+
@__fontinfo ||= {}
|
|
45
|
+
@__fontinfo[info[:cbid]] = {
|
|
46
|
+
:font => pdf.current_font,
|
|
47
|
+
:base_font => pdf.current_base_font,
|
|
48
|
+
:info => info
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
pdf.select_font(@font_name, @font_encoding)
|
|
52
|
+
|
|
53
|
+
{ :font_change => true }
|
|
54
|
+
when :end, :end_line
|
|
55
|
+
fi = @__fontinfo[info[:cbid]]
|
|
56
|
+
|
|
57
|
+
pdf.font_size = fi[:font_size]
|
|
58
|
+
pdf.select_font(fi[:base_font])
|
|
59
|
+
pdf.select_font(fi[:font])
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
PDF::Writer::TAGS[:pair]["code"] = TagCodeFont
|
|
66
|
+
|
|
67
|
+
pdf.text "Hello, <c:code>Ruby</c:code>.", :font_size => 72, :justification => :center
|
|
68
|
+
pdf.move_pointer(80)
|
|
69
|
+
pdf.text "This is a longer <c:code>sample of code font text</c:code>. What do you think?", :font_size => 12, :justification => :full
|
|
70
|
+
|
|
71
|
+
pdf.save_as("code.pdf")
|
data/demo/colornames.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# PDF::Writer for Ruby.
|
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
|
7
|
+
# for full licensing information.
|
|
8
|
+
#
|
|
9
|
+
# $Id$
|
|
10
|
+
#++
|
|
11
|
+
begin
|
|
12
|
+
require 'pdf/writer'
|
|
13
|
+
rescue LoadError => le
|
|
14
|
+
if le.message =~ %r{pdf/writer$}
|
|
15
|
+
$LOAD_PATH.unshift("../lib")
|
|
16
|
+
require 'pdf/writer'
|
|
17
|
+
else
|
|
18
|
+
raise
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
require 'color/rgb/metallic'
|
|
23
|
+
|
|
24
|
+
pdf = PDF::Writer.new
|
|
25
|
+
|
|
26
|
+
pdf.start_columns 4
|
|
27
|
+
|
|
28
|
+
colours = Color::RGB.constants.sort
|
|
29
|
+
|
|
30
|
+
colours.each do |colour|
|
|
31
|
+
next if colour == "PDF_FORMAT_STR"
|
|
32
|
+
next if colour == "Metallic"
|
|
33
|
+
pdf.fill_color Color::RGB.const_get(colour)
|
|
34
|
+
pdf.text colour, :font_size => 24
|
|
35
|
+
pdf.fill_color Color::RGB::Black
|
|
36
|
+
pdf.text colour, :font_size => 12, :justification => :center
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
colours = Color::RGB::Metallic.constants.sort
|
|
40
|
+
colours.each do |colour|
|
|
41
|
+
pdf.fill_color Color::RGB::Metallic.const_get(colour)
|
|
42
|
+
pdf.text colour, :font_size => 24
|
|
43
|
+
pdf.fill_color Color::RGB::Black
|
|
44
|
+
pdf.text colour, :font_size => 12, :justification => :center
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
pdf.save_as "colornames.pdf"
|