pdf-writer 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +34 -5
- data/LICENCE +17 -10
- data/demo/demo.rb +5 -5
- data/demo/gettysburg.rb +2 -2
- data/demo/qr-language.rb +3 -4
- data/demo/qr-library.rb +3 -2
- data/images/bluesmoke.jpg +0 -0
- data/lib/pdf/charts/stddev.rb +7 -7
- data/lib/pdf/quickref.rb +4 -4
- data/lib/pdf/simpletable.rb +8 -7
- data/lib/pdf/techbook.rb +14 -12
- data/lib/pdf/writer.rb +177 -53
- data/lib/pdf/writer/fontmetrics.rb +2 -1
- data/lib/pdf/writer/graphics.rb +97 -11
- data/lib/pdf/writer/lang/en.rb +23 -2
- data/lib/pdf/writer/object/font.rb +20 -28
- data/lib/pdf/writer/object/fontencoding.rb +11 -10
- data/manual.pwd +623 -176
- metadata +3 -6
- data/bin/techbook.bat +0 -2
- data/images/pdfwriter-icon.jpg +0 -0
- data/images/pdfwriter-small.jpg +0 -0
- data/images/pdfwriter-tiny.jpg +0 -0
data/ChangeLog
CHANGED
@@ -1,11 +1,40 @@
|
|
1
1
|
= PDF::Writer Change Log
|
2
2
|
|
3
|
-
== PDF::Writer 1.0
|
3
|
+
== PDF::Writer 1.1.0: June 29, 2005
|
4
|
+
NOTE: The first two changes are INCOMPATIBLE with previous versions of
|
5
|
+
PDF::Writer. If you find that your text is showing up at odd angles, negate
|
6
|
+
the value. That is, if you have 90 as your angle, use -90 (or 270) as your
|
7
|
+
angle and it will work like it used to.
|
8
|
+
|
9
|
+
* Axis transformations in PDF::Writer::Graphics have been fixed.
|
10
|
+
* Text axis transformation in PDF::Writer#add_text has been fixed.
|
11
|
+
* Changed #text_width and #text_line_width so that the text value is the
|
12
|
+
first parameter and the size parameter is second, and is optional. The code
|
13
|
+
warns about it now, but it will break in PDF::Writer 2.0.
|
14
|
+
* Changed #add_text and #add_text_wrap so that the text parameter is before
|
15
|
+
the now-optional size parameter. The code warns about it now, but it will
|
16
|
+
break in PDF::Writer 2.0.
|
17
|
+
* Added #transform_matrix.
|
18
|
+
* Fixed compression. NOTE: Compression must be set early in the documentation
|
19
|
+
process, or only some items will be compressed in the document. The various
|
20
|
+
#save_as methods have been changed to reflect this fact.
|
21
|
+
* Enabled the placement of encoding differences dictionaries in the resulting
|
22
|
+
PDF document. This change should be considered experimental.
|
23
|
+
* Added TTF licence checking. The embedding of a file not licenced for
|
24
|
+
inclusion in a document will continue, but a warning will be output to
|
25
|
+
standard error. This code has been gakked from FPDF (http://www.fpdf.org).
|
26
|
+
* Properly supporting symbolic font flags now.
|
27
|
+
* Added support and documentation for a separately downloadable demo package.
|
28
|
+
* Expanded the installation documentation.
|
29
|
+
* Added the ability to make images clickable links with any of the three
|
30
|
+
image insertion methods.
|
31
|
+
|
32
|
+
== PDF::Writer 1.0.1: June 13, 2005
|
4
33
|
* Fixed a few minor gem issues.
|
5
34
|
* Renamed bin/manual to bin/techbook.
|
6
35
|
* Fixed the manual.pwd locator for the default install.
|
7
36
|
|
8
|
-
== PDF::Writer 1.0.0
|
37
|
+
== PDF::Writer 1.0.0: June 12, 2005
|
9
38
|
* Integrated ezwriter.rb functionality with writer.rb.
|
10
39
|
* Factored out some functionality into modules and classes.
|
11
40
|
* Added CMYK colour support to JPEG images.
|
@@ -28,12 +57,12 @@
|
|
28
57
|
component characters, not the represented characters.
|
29
58
|
* Fixed a performance bug. Thanks again to Leslie Hensley.
|
30
59
|
|
31
|
-
== PDF::Writer 0.1.2
|
60
|
+
== PDF::Writer 0.1.2: CVS only
|
32
61
|
* Fixed a problem with the improper reading of character numbers from .afm
|
33
62
|
files that are not default files. Other font issues remain but will be fixed
|
34
63
|
at a later date.
|
35
64
|
|
36
|
-
== PDF::Writer 0.1.0
|
65
|
+
== PDF::Writer 0.1.0: September, 2003
|
37
66
|
* Initial technology preview.
|
38
67
|
|
39
68
|
#--
|
@@ -44,6 +73,6 @@
|
|
44
73
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
45
74
|
# for full licensing information.
|
46
75
|
#
|
47
|
-
# $Id: ChangeLog,v 1.
|
76
|
+
# $Id: ChangeLog,v 1.16 2005/06/29 10:25:50 austin Exp $
|
48
77
|
#++
|
49
78
|
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/LICENCE
CHANGED
@@ -26,7 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
27
27
|
|
28
28
|
== Works Included Under Other Licences
|
29
|
-
===
|
29
|
+
=== pdf/writer/graphics/imageinfo.rb
|
30
30
|
PDF::Writer includes a derivative of Keisuke Minami's ImageSize library,
|
31
31
|
which can be found at rubycgi[http://www.rubycgi.org/tools/index.en.htm].
|
32
32
|
This work�and only this or other named works�may be treated as under the Ruby
|
@@ -48,13 +48,13 @@ Attributions ShareAlike[http://creativecommons.org/licenses/by-sa/2.0/]
|
|
48
48
|
licence.
|
49
49
|
|
50
50
|
=== Adobe PostScript AFM Files
|
51
|
-
|
52
|
-
used, copied, and distributed for any purpose and without
|
53
|
-
without modification, provided that all copyright notices are
|
54
|
-
the AFM files are not distributed without this file; that all
|
55
|
-
to this file or any of the AFM files are prominently noted in
|
56
|
-
file(s); and that this paragraph is not modified. Adobe Systems
|
57
|
-
responsibility or obligation to support the use of the AFM files.
|
51
|
+
pdf/writer/fonts/MustRead.html and the 14 PostScript(R) AFM files it
|
52
|
+
accompanies may be used, copied, and distributed for any purpose and without
|
53
|
+
charge, with or without modification, provided that all copyright notices are
|
54
|
+
retained; that the AFM files are not distributed without this file; that all
|
55
|
+
modifications to this file or any of the AFM files are prominently noted in
|
56
|
+
the modified file(s); and that this paragraph is not modified. Adobe Systems
|
57
|
+
has no responsibility or obligation to support the use of the AFM files.
|
58
58
|
|
59
59
|
== Other Credits
|
60
60
|
=== PDF::Writer
|
@@ -62,11 +62,18 @@ PDF::Writer is based originally on the R & OS PDF class for
|
|
62
62
|
PHP[http://www.ros.co.nz/pdf/], which is released as public domain.
|
63
63
|
|
64
64
|
=== Standard Deviation Chart
|
65
|
-
The standard deviation chart (
|
65
|
+
The standard deviation chart (pdf/charts/stddev.rb) class is based on
|
66
66
|
work by Cris Ewing[mailto:cewing@u.washington.edu] of the University of
|
67
67
|
Washington School of Medicine, originally created for the R & OS PDF class
|
68
68
|
for PHP. He has graciously donated the code for PDF::Writer for Ruby.
|
69
69
|
|
70
|
+
=== bluesmoke.jpg
|
71
|
+
The logo image for PDF::Writer, bluesmoke.jpg, is modified from a picture
|
72
|
+
taken by Matthew "TheSaint" Bowden[mailto:matthewbowden@gmail.com] and is
|
73
|
+
available on the stock.xchng(R) at
|
74
|
+
<http://www.sxc.hu/browse.phtml?f=view&id=275430>. Many thanks to Matthew for
|
75
|
+
the use of this image.
|
76
|
+
|
70
77
|
== Patents Covering the Adobe PDF Format
|
71
78
|
=== ADOBE PATENTS
|
72
79
|
This software is based on Adobe's PDF Reference, Third Edition, version 1.6.
|
@@ -114,5 +121,5 @@ feature for any purpose other than as set forth in the applicable license
|
|
114
121
|
grant. Adobe has other patents in various fields, none of which are hereby
|
115
122
|
licensed.
|
116
123
|
|
117
|
-
$Id: LICENCE,v 1.
|
124
|
+
$Id: LICENCE,v 1.10 2005/06/29 19:32:07 austin Exp $
|
118
125
|
# vim: sts=2 sw=2 ts=4 et ai tw=77
|
data/demo/demo.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: demo.rb,v 1.
|
9
|
+
# $Id: demo.rb,v 1.8 2005/06/29 03:00:31 austin Exp $
|
10
10
|
#++
|
11
11
|
begin
|
12
12
|
require 'pdf/writer'
|
@@ -59,15 +59,15 @@ y = 800
|
|
59
59
|
height = pdf.font_height(size)
|
60
60
|
y = y - height
|
61
61
|
|
62
|
-
pdf.add_text(30, y,
|
62
|
+
pdf.add_text(30, y, line, size)
|
63
63
|
end
|
64
64
|
|
65
65
|
(0...360).step(20) do |angle|
|
66
66
|
pdf.fill_color(Color::RGB.from_fraction(rand, rand, rand))
|
67
67
|
|
68
68
|
pdf.add_text(300 + Math.cos(PDF::Math.deg2rad(angle)) * 40,
|
69
|
-
300
|
70
|
-
|
69
|
+
300 + Math.sin(PDF::Math.deg2rad(angle)) * 40,
|
70
|
+
line, 20, angle)
|
71
71
|
end
|
72
72
|
|
73
|
-
pdf.save_as("demo.pdf"
|
73
|
+
pdf.save_as("demo.pdf")
|
data/demo/gettysburg.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: gettysburg.rb,v 1.
|
9
|
+
# $Id: gettysburg.rb,v 1.5 2005/06/15 21:38:38 austin Exp $
|
10
10
|
#++
|
11
11
|
begin
|
12
12
|
require 'pdf/writer'
|
@@ -47,7 +47,7 @@ government of the people, by the people, for the people shall
|
|
47
47
|
not perish from the earth.
|
48
48
|
EOS
|
49
49
|
|
50
|
-
gba = GETTYSBURG.split($/).join(" ").squeeze
|
50
|
+
gba = GETTYSBURG.split($/).join(" ").squeeze(" ")
|
51
51
|
|
52
52
|
pdf.text "The Gettysburg Address\n\n", :font_size => 36,
|
53
53
|
:justification => :center
|
data/demo/qr-language.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# See LICENCE in the main distribution for full licensing information.
|
12
12
|
#
|
13
|
-
# $Id: qr-language.rb,v 1.
|
13
|
+
# $Id: qr-language.rb,v 1.14 2005/06/29 19:57:30 austin Exp $
|
14
14
|
#++
|
15
15
|
begin
|
16
16
|
require 'pdf/writer'
|
@@ -42,6 +42,7 @@ usage: #{File.basename($0)} [paper-size]
|
|
42
42
|
end
|
43
43
|
|
44
44
|
PDF::QuickRef.make(paper, 3) do
|
45
|
+
pdf.compressed = true
|
45
46
|
pdf.info.author = "Ryan Davis"
|
46
47
|
pdf.info.title = "Ruby Language Quick Reference"
|
47
48
|
pdf.info.subject = "The Ruby Programming Language"
|
@@ -571,11 +572,9 @@ end
|
|
571
572
|
x = pdf.absolute_right_margin + pdf.font_height(5)
|
572
573
|
y = pdf.absolute_bottom_margin
|
573
574
|
memo = %Q(Copyright � 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
|
574
|
-
pdf.add_text(x, y,
|
575
|
+
pdf.add_text(x, y, memo, 5, 90)
|
575
576
|
x = pdf.absolute_right_margin - 32
|
576
577
|
y = pdf.absolute_bottom_margin + 24
|
577
578
|
|
578
|
-
pdf.add_image_from_file("../images/pdfwriter-icon.jpg", x, y)
|
579
|
-
|
580
579
|
save_as "Ruby-Language-QuickRef.pdf"
|
581
580
|
end
|
data/demo/qr-library.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# See LICENCE in the main distribution for full licensing information.
|
12
12
|
#
|
13
|
-
# $Id: qr-library.rb,v 1.
|
13
|
+
# $Id: qr-library.rb,v 1.7 2005/06/29 03:12:11 austin Exp $
|
14
14
|
#++
|
15
15
|
begin
|
16
16
|
require 'pdf/writer'
|
@@ -42,6 +42,7 @@ usage: #{File.basename($0)} [paper-size]
|
|
42
42
|
end
|
43
43
|
|
44
44
|
PDF::QuickRef.make(paper, 3) do
|
45
|
+
pdf.compressed = true
|
45
46
|
pdf.info.author = "Ryan Davis"
|
46
47
|
pdf.info.title = "Ruby Library Quick Reference"
|
47
48
|
pdf.info.subject = "The Ruby Standard Library"
|
@@ -371,7 +372,7 @@ empty A null command repeats the last command.
|
|
371
372
|
x = pdf.absolute_right_margin + pdf.font_height(5)
|
372
373
|
y = pdf.absolute_bottom_margin
|
373
374
|
memo = %Q(Copyright � 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
|
374
|
-
pdf.add_text(x, y,
|
375
|
+
pdf.add_text(x, y, memo, 5, 90)
|
375
376
|
x = pdf.absolute_right_margin - 32
|
376
377
|
y = pdf.absolute_bottom_margin + 24
|
377
378
|
|
Binary file
|
data/lib/pdf/charts/stddev.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: stddev.rb,v 1.
|
9
|
+
# $Id: stddev.rb,v 1.8 2005/06/28 21:32:17 austin Exp $
|
10
10
|
#++
|
11
11
|
require 'pdf/writer'
|
12
12
|
require 'pdf/charts'
|
@@ -20,7 +20,7 @@ require 'ostruct'
|
|
20
20
|
# The scale of responses is the vertical scale; the average data points
|
21
21
|
# and standard deviation values are the horizontal scale.
|
22
22
|
class PDF::Charts::StdDev
|
23
|
-
VERSION = '1.0
|
23
|
+
VERSION = '1.1.0'
|
24
24
|
|
25
25
|
# A data element.
|
26
26
|
DataPoint = Struct.new(:label, :average, :stddev)
|
@@ -264,7 +264,7 @@ class PDF::Charts::StdDev
|
|
264
264
|
|
265
265
|
if @scale.show_labels
|
266
266
|
scales.each_value do |scale|
|
267
|
-
this_width = pdf.text_width(@scale.label.text_size
|
267
|
+
this_width = pdf.text_width(scale.value, @scale.label.text_size)
|
268
268
|
widest_scale_label = this_width if this_width > widest_scale_label
|
269
269
|
end
|
270
270
|
end
|
@@ -322,10 +322,10 @@ class PDF::Charts::StdDev
|
|
322
322
|
|
323
323
|
data.each_with_index do |datum, ii|
|
324
324
|
label = datum.label.to_s
|
325
|
-
label_width = pdf.text_width(@label.text_size
|
325
|
+
label_width = pdf.text_width(label, @label.text_size)
|
326
326
|
this_x = chart_x + (ii * chunk_width) + (chunk_width / 2.0) - (label_width / 2.0)
|
327
327
|
this_y = chart_y + (@label.height / 2.0) - (@label.text_size / 3.0)
|
328
|
-
pdf.add_text(this_x, this_y, @label.text_size
|
328
|
+
pdf.add_text(this_x, this_y, label, @label.text_size)
|
329
329
|
end
|
330
330
|
pdf.restore_state
|
331
331
|
end
|
@@ -362,10 +362,10 @@ class PDF::Charts::StdDev
|
|
362
362
|
pdf.save_state
|
363
363
|
scales.each_value do |scale|
|
364
364
|
this_y = chart_y + scale.label_height
|
365
|
-
label_width = pdf.text_width(@scale.label.text_size
|
365
|
+
label_width = pdf.text_width(scale.value, @scale.label.text_size)
|
366
366
|
this_x = chart_x - label_width - @scale.label.pad
|
367
367
|
pdf.fill_color! @scale.label.text_color
|
368
|
-
pdf.add_text(this_x, this_y, @scale.label.text_size
|
368
|
+
pdf.add_text(this_x, this_y, scale.value, @scale.label.text_size)
|
369
369
|
end
|
370
370
|
pdf.restore_state
|
371
371
|
end
|
data/lib/pdf/quickref.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: quickref.rb,v 1.
|
9
|
+
# $Id: quickref.rb,v 1.9 2005/06/16 04:28:25 austin Exp $
|
10
10
|
#++
|
11
11
|
require 'pdf/simpletable'
|
12
12
|
|
@@ -51,7 +51,7 @@ require 'pdf/simpletable'
|
|
51
51
|
# qr.lines "Text to put after the header."
|
52
52
|
# qr.save_as "MyQuickRef.pdf"
|
53
53
|
class PDF::QuickRef
|
54
|
-
VERSION = '1.0
|
54
|
+
VERSION = '1.1.0'
|
55
55
|
|
56
56
|
# Create the quick reference document. +paper+ is passed unchanged to
|
57
57
|
# the PDF::Writer.new; the page is always created landscape. Margins
|
@@ -301,8 +301,8 @@ class PDF::QuickRef
|
|
301
301
|
end
|
302
302
|
|
303
303
|
# Writes the Quick Reference to disk.
|
304
|
-
def save_as(filename
|
305
|
-
@pdf.save_as(filename
|
304
|
+
def save_as(filename)
|
305
|
+
@pdf.save_as(filename)
|
306
306
|
end
|
307
307
|
|
308
308
|
# Generates the PDF document as a string.
|
data/lib/pdf/simpletable.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
7
|
# for full licensing information.
|
8
8
|
#
|
9
|
-
# $Id: simpletable.rb,v 1.
|
9
|
+
# $Id: simpletable.rb,v 1.12 2005/06/28 21:32:17 austin Exp $
|
10
10
|
#++
|
11
11
|
require 'pdf/writer'
|
12
12
|
require 'transaction/simple/group'
|
@@ -14,7 +14,7 @@ require 'transaction/simple/group'
|
|
14
14
|
# This class will create tables with a relatively simple API and internal
|
15
15
|
# implementation.
|
16
16
|
class PDF::SimpleTable
|
17
|
-
VERSION = '1.0
|
17
|
+
VERSION = '1.1.0'
|
18
18
|
|
19
19
|
include Transaction::Simple
|
20
20
|
|
@@ -410,7 +410,7 @@ class PDF::SimpleTable
|
|
410
410
|
|
411
411
|
# If the title is set, then render it.
|
412
412
|
unless @title.nil? or @title.empty?
|
413
|
-
w = pdf.text_width(@
|
413
|
+
w = pdf.text_width(@title, @title_font_size)
|
414
414
|
_y = pdf.y - pdf.font_height(@title_font_size)
|
415
415
|
if _y < pdf.absolute_bottom_margin
|
416
416
|
pdf.start_new_page
|
@@ -425,7 +425,7 @@ class PDF::SimpleTable
|
|
425
425
|
|
426
426
|
pdf.y -= pdf.font_height(@title_font_size)
|
427
427
|
pdf.fill_color @title_color
|
428
|
-
pdf.add_text(middle - w / 2.0, pdf.y, @title_font_size
|
428
|
+
pdf.add_text(middle - w / 2.0, pdf.y, title, @title_font_size)
|
429
429
|
pdf.y -= @title_gap
|
430
430
|
end
|
431
431
|
|
@@ -646,7 +646,8 @@ class PDF::SimpleTable
|
|
646
646
|
|
647
647
|
pdf.y = _y
|
648
648
|
line = pdf.add_text_wrap(pos[name], pdf.y,
|
649
|
-
|
649
|
+
max_width[name], line,
|
650
|
+
@font_size, just)
|
650
651
|
end
|
651
652
|
end
|
652
653
|
end
|
@@ -776,7 +777,7 @@ class PDF::SimpleTable
|
|
776
777
|
# some analysis first.
|
777
778
|
@data.each do |row|
|
778
779
|
@cols.each do |name, column|
|
779
|
-
w = pdf.text_width(
|
780
|
+
w = pdf.text_width(row[name].to_s, @font_size)
|
780
781
|
w *= WIDTH_FACTOR
|
781
782
|
|
782
783
|
max_width[name] = w if w > max_width[name]
|
@@ -786,7 +787,7 @@ class PDF::SimpleTable
|
|
786
787
|
@cols.each do |name, column|
|
787
788
|
title = column.heading.title if column.heading
|
788
789
|
title ||= column.name
|
789
|
-
w = pdf.text_width(@heading_font_size
|
790
|
+
w = pdf.text_width(title, @heading_font_size)
|
790
791
|
w *= WIDTH_FACTOR
|
791
792
|
max_width[name] = w if w > max_width[name]
|
792
793
|
end
|
data/lib/pdf/techbook.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
8
8
|
# for full licensing information.
|
9
9
|
#
|
10
|
-
# $Id: techbook.rb,v 1.
|
10
|
+
# $Id: techbook.rb,v 1.16 2005/06/28 21:32:17 austin Exp $
|
11
11
|
#++
|
12
12
|
require 'pdf/simpletable'
|
13
13
|
require 'pdf/charts/stddev'
|
@@ -65,10 +65,10 @@ require 'ostruct'
|
|
65
65
|
#
|
66
66
|
# === Styling and Callback Tags
|
67
67
|
# Within normal, preserved, or code text, or in headings, HTML-like markup
|
68
|
-
# may be used for bold (<b>)
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
68
|
+
# may be used for bold (<b>) and italic (<i>) text. TechBook
|
69
|
+
# supports standard PDF::Writer callback tags (<c:alink>, <c:ilink>,
|
70
|
+
# <C:bullet/>, and <C:disc/>) and adds two new ones (<r:xref/>,
|
71
|
+
# <C:tocdots/>).
|
72
72
|
#
|
73
73
|
# <tt><r:xref/></tt>:: Creates an internal document link to the
|
74
74
|
# named cross-reference destination. Works
|
@@ -242,8 +242,9 @@ class PDF::TechBook < PDF::Writer
|
|
242
242
|
# used for forward references; only +title+ or +text+ will be
|
243
243
|
# used.
|
244
244
|
# text:: Required if +label+ has a value of +text+. Ignored if +label+
|
245
|
-
# is +title+, optional if +label+ is +
|
246
|
-
# used as the display for the internal link.
|
245
|
+
# is +title+, optional if +label+ is +page+. This value will be
|
246
|
+
# used as the display text for the internal link. +text+
|
247
|
+
# takes precedence over +title+ if +label+ is +page+.
|
247
248
|
class TagXref
|
248
249
|
def self.[](pdf, params)
|
249
250
|
name = params["name"]
|
@@ -256,9 +257,9 @@ class PDF::TechBook < PDF::Writer
|
|
256
257
|
when 'page'
|
257
258
|
label = xref[:page]
|
258
259
|
if text.nil? or text.empty?
|
259
|
-
label ||= text
|
260
|
-
else
|
261
260
|
label ||= xref[:title]
|
261
|
+
else
|
262
|
+
label ||= text
|
262
263
|
end
|
263
264
|
when 'title'
|
264
265
|
label = xref[:title]
|
@@ -344,7 +345,7 @@ class PDF::TechBook < PDF::Writer
|
|
344
345
|
|
345
346
|
pdf.line(xpos, info[:y], info[:x] + 5, info[:y]).stroke
|
346
347
|
pdf.restore_state
|
347
|
-
pdf.add_text(xpos + 5, info[:y],
|
348
|
+
pdf.add_text(xpos + 5, info[:y], page, size)
|
348
349
|
end
|
349
350
|
end
|
350
351
|
end
|
@@ -854,7 +855,7 @@ class PDF::TechBook < PDF::Writer
|
|
854
855
|
if (_tm_doc < _tm_cch) and (_tm_prg < _tm_cch)
|
855
856
|
$stderr.puts PDF::Writer::Lang[:techbook_using_cached_doc] % File.basename(files[:cache])
|
856
857
|
pdf = File.open(files[:cache], "rb") { |cf| Marshal.load(cf.read) }
|
857
|
-
pdf.save_as(files[:pdf]
|
858
|
+
pdf.save_as(files[:pdf])
|
858
859
|
File.open(files[:pdf], "wb") { |pf| pf.write pdf.render }
|
859
860
|
exit(0)
|
860
861
|
else
|
@@ -867,6 +868,7 @@ class PDF::TechBook < PDF::Writer
|
|
867
868
|
|
868
869
|
# Create the manual object.
|
869
870
|
pdf = PDF::TechBook.new
|
871
|
+
pdf.compressed = config.compressed
|
870
872
|
pdf.techbook_source_dir = File.expand_path(dirn)
|
871
873
|
|
872
874
|
document = open(files[:document]) { |io| io.read.split($/) }
|
@@ -884,7 +886,7 @@ class PDF::TechBook < PDF::Writer
|
|
884
886
|
File.open(files[:cache], "wb") { |f| f.write Marshal.dump(pdf) }
|
885
887
|
end
|
886
888
|
|
887
|
-
pdf.save_as(files[:pdf]
|
889
|
+
pdf.save_as(files[:pdf])
|
888
890
|
end
|
889
891
|
|
890
892
|
def techbook_text(line)
|