pdf-writer 1.0.1 → 1.1.0

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.
@@ -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: en.rb,v 1.7 2005/06/08 12:16:11 austin Exp $
9
+ # $Id: en.rb,v 1.9 2005/06/28 21:32:17 austin Exp $
10
10
  #++
11
11
  # PDF::Writer::Lang::EN is the English-language output module. It contains a
12
12
  # hash, @message, that contains the messages that may be reported by any
@@ -19,6 +19,26 @@ module PDF::Writer::Lang::EN
19
19
  :invalid_pos => ":pos must be either :before or :after.",
20
20
  :req_FPXO => "Pages#<< requires a PDF::Writer::Page, PDF::Writer::Font, or PDF::Writer::ExternalObject.",
21
21
  :req_FPXOH => "Pages#add requires a PDF::Writer::Page, PDF::Writer::Font, PDF::Writer::ExternalObject, or Hash.",
22
+ :text_width_parameters_reversed => <<-EOS,
23
+ %s
24
+ As of PDF::Writer 1.1, the signature for #text_width and #text_line_width
25
+ is (text, size), not (size, text). It appears that the old version is still
26
+ in use in your code. Please change it.
27
+ EOS
28
+ :add_text_parameters_reversed => <<-EOS,
29
+ %s
30
+ As of PDF::Writer 1.1, the signature for #add_text is (x, y, text, size,
31
+ angle, word_space_adjust), not (x, y, size, text, angle, word_space_adjust).
32
+ It appears that the old version is still in use in your code. Please change
33
+ it.
34
+ EOS
35
+ :add_textw_parameters_reversed => <<-EOS,
36
+ %s
37
+ As of PDF::Writer 1.1, the signature for #add_text_wrap is (x, y, text,
38
+ size, justification, angle, test), not (x, y, size, text, justification,
39
+ angle, test). It appears that the old version is still in use in your
40
+ code. Please change it.
41
+ EOS
22
42
  :png_invalid_header => "Invalid PNG header.",
23
43
  :png_unsupp_compres => "Unsupported PNG compression method.",
24
44
  :png_unsupp_filter => "Unsupported PNG filter method.",
@@ -28,9 +48,10 @@ module PDF::Writer::Lang::EN
28
48
  :data_must_be_array => "The table data is not an Array. (Temporary limitation.)",
29
49
  :columns_unspecified => "Columns are unspecified. They must be data[0] and be an array.",
30
50
  :no_zlib_no_compress => "Could not load Zlib. PDF compression is disabled.",
51
+ :ttf_licence_no_embedding => "The TrueType font %1s has a licence that does not allow for embedding.",
31
52
  :simpletable_columns_undefined => "Columns are undefined for table.",
32
53
  :simpletable_data_empty => "Table data is empty.",
33
- :techbook_eval_exception => <<-EOS ,
54
+ :techbook_eval_exception => <<-EOS,
34
55
 
35
56
  Error in document around line %d:
36
57
  %s
@@ -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: font.rb,v 1.3 2005/05/25 11:19:50 austin Exp $
9
+ # $Id: font.rb,v 1.5 2005/06/28 21:32:17 austin Exp $
10
10
  #++
11
11
  # An object to hold the font description
12
12
  class PDF::Writer::Object::Font < PDF::Writer::Object
@@ -17,44 +17,36 @@ class PDF::Writer::Object::Font < PDF::Writer::Object
17
17
 
18
18
  @name = name
19
19
  @subtype = subtype
20
- @encoding = encoding
21
-
22
20
  @font_id = @parent.__send__(:generate_font_id)
23
21
 
24
22
  if encoding.kind_of?(PDF::Writer::Object::FontEncoding)
25
- @encoding = nil
26
- @encodingDictionary = encoding
23
+ @encoding = encoding
27
24
  elsif encoding == 'none' or encoding.nil?
28
- @encoding = nil
25
+ @encoding = nil
26
+ else
27
+ @encoding = encoding
29
28
  end
30
29
 
31
30
  @parent.pages << self
32
31
 
33
- @encodingDictionary = nil
34
- @firstchar = nil
35
- @lastchar = nil
36
- @widths = nil
37
- @fontdescriptor = nil
32
+ @firstchar = nil
33
+ @lastchar = nil
34
+ @widths = nil
35
+ @fontdescriptor = nil
38
36
  end
39
37
 
40
38
  attr_reader :font_id
41
- attr_accessor :subtype
39
+ # The type of the font: Type1 and TrueType are the only values supported
40
+ # by
41
+ attr_reader :subtype
42
42
  # Valid values: WinAnsiEncoding, MacRomanEncoding, MacExpertEncoding,
43
- # none, +nil+
44
- attr_accessor :encoding
45
- attr_reader :encodingDictionary
46
- def encodingDictionary=(ed)
47
- @encodingDictionary = ed
48
- end
49
-
50
- def basefont
43
+ # none, +nil+, or an instance of PDF::Writer::Object::FontEncoding.
44
+ attr_reader :encoding
45
+ attr_reader :basefont
46
+ def basefont #:nodoc:
51
47
  @name
52
48
  end
53
49
 
54
- def basefont=(b)
55
- @name = basefont
56
- end
57
-
58
50
  Details.each do |d|
59
51
  attr_accessor d.downcase.intern
60
52
  end
@@ -62,10 +54,10 @@ class PDF::Writer::Object::Font < PDF::Writer::Object
62
54
  def to_s
63
55
  res = "\n#{@oid} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
64
56
  res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
65
- if @encodingDictionary.nil?
66
- res << "/Encoding /#{@encoding}\n"
67
- else
68
- res << "/Encoding #{@encodingDictionary.oid} 0 R\n"
57
+ if @encoding.kind_of?(PDF::Writer::Object::FontEncoding)
58
+ res << "/Encoding #{@encoding.oid} 0 R\n"
59
+ elsif @encoding
60
+ res << "/Encoding /#{@encoding}\n" if @encoding
69
61
  end
70
62
  res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil?
71
63
  res << "/LastChar #{@lastchar}\n" unless @lastchar.nil?
@@ -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: fontencoding.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
9
+ # $Id: fontencoding.rb,v 1.4 2005/06/28 21:32:17 austin Exp $
10
10
  #++
11
11
  # The font encoding
12
12
  class PDF::Writer::Object::FontEncoding < PDF::Writer::Object
@@ -24,16 +24,17 @@ class PDF::Writer::Object::FontEncoding < PDF::Writer::Object
24
24
  res = "\n#{@oid} 0 obj\n<< /Type /Encoding\n"
25
25
  enc = @encoding || 'WinAnsiEncoding'
26
26
  res << "/BaseEncoding /#{enc}\n" unless enc == 'none'
27
- res << "/Differences \n["
28
- n = -100
29
- differences.each do |k, v|
30
- if k != (n + 1)
31
- res << "\n#{k} /#{v}" # Cannot make use of consecutive numbering
32
- else
33
- res << " /#{v}"
27
+ unless @differences.nil? or @differences.empty?
28
+ res << "/Differences \n["
29
+ n = nil
30
+ @differences.keys.sort.each do |k|
31
+ # Cannot make use of consecutive numbering
32
+ res << "\n#{k} " if n.nil? or k != (n + 1)
33
+ res << " /#{@differences[k]}"
34
+ n = k
34
35
  end
35
- n = k
36
+ res << "\n]"
36
37
  end
37
- res << "\n]\n>>\nendobj"
38
+ res << "\n>>\nendobj"
38
39
  end
39
40
  end
data/manual.pwd CHANGED
@@ -1,4 +1,4 @@
1
- # This is the main manual for PDF::Writer. It is interpreted by manual.rb,
1
+ # This is the main manual for PDF::Writer. It is interpreted by PDF::TechBook
2
2
  # which implements an interpreter for the simple markup language presented
3
3
  # here.
4
4
  #
@@ -100,8 +100,8 @@
100
100
  pdf.techbook_encoding = {
101
101
  :encoding => 'WinAnsiEncoding',
102
102
  :differences => {
103
+ 169 => "copyright",
103
104
  215 => "multiply",
104
- 148 => "copyright",
105
105
  }
106
106
  }
107
107
  .endeval }}}
@@ -116,10 +116,10 @@ pdf.open_object do |heading|
116
116
 
117
117
  s = 6
118
118
  t = "PDF::Writer for Ruby ~ Manual"
119
- w = pdf.text_width(s, t) / 2.0
119
+ w = pdf.text_width(t, s) / 2.0
120
120
  x = pdf.margin_x_middle
121
121
  y = pdf.absolute_top_margin
122
- pdf.add_text(x - w, y, s, t)
122
+ pdf.add_text(x - w, y, t, s)
123
123
 
124
124
  x = pdf.absolute_left_margin
125
125
  w = pdf.absolute_right_margin
@@ -141,7 +141,7 @@ pdf.open_object do |footing|
141
141
  t = "http://rubyforge.org/projects/ruby-pdf"
142
142
  x = pdf.absolute_left_margin
143
143
  y = pdf.absolute_bottom_margin
144
- pdf.add_text(x, y, s, t)
144
+ pdf.add_text(x, y, t, s)
145
145
 
146
146
  x = pdf.absolute_left_margin
147
147
  w = pdf.absolute_right_margin
@@ -163,6 +163,9 @@ pnx = pdf.absolute_right_margin
163
163
  pdf.margins_pt(54) # 54 point (3/4") margins on all sides...
164
164
  pdf.left_margin = 72 # ...except the left margin (1")
165
165
 
166
+ image = File.join(pdf.techbook_source_dir, "images", "bluesmoke.jpg")
167
+ pdf.add_image_from_file(image, 300, 50)
168
+
166
169
  # Draw the title page.
167
170
  title = "PDF::Writer for Ruby"
168
171
  size = 72
@@ -174,7 +177,7 @@ pdf.stroke_color Color::Red
174
177
  pdf.rectangle(pdf.absolute_left_margin, 0, fh, pdf.page_height).fill
175
178
  pdf.fill_color Color::White
176
179
  pdf.stroke_color Color::White
177
- pdf.add_text(pdf.absolute_left_margin + fh + fd, 70, size, title, -90)
180
+ pdf.add_text(pdf.absolute_left_margin + fh + fd, 70, title, size, 90)
178
181
  pdf.restore_state
179
182
 
180
183
  pdf.select_font pdf.techbook_textfont, pdf.techbook_encoding
@@ -196,8 +199,6 @@ Copyright
196
199
  INFO
197
200
 
198
201
  pdf.text(info, :font_size => 18, :justification => :right)
199
- image = File.join(pdf.techbook_source_dir, "images", "pdfwriter-small.jpg")
200
- pdf.add_image_from_file(image, 400, 100)
201
202
  pdf.open_here('Fit')
202
203
 
203
204
  pdf.start_page_numbering(pnx, pny, 6, :right, "<PAGENUM>", 1)
@@ -217,10 +218,11 @@ but it implements a substantial portion of it, with more to come. It also
217
218
  implements a more complex document layer on top of the portion that is
218
219
  implemented.
219
220
 
220
- The program (manual.rb) and text file (manual.txt) that generate this manual
221
- (manual.pdf) are a good introduction to both the use of PDF::Writer and a
222
- sample markup language. PDF::Writer itself only implements a few markup
223
- items, mostly relating to bold and italic text.
221
+ This manual (manual.pdf) is generated by PDF::TechBook using the application
222
+ runner (bin/techbook) and the text version of the manual (manual.pwd). It is
223
+ a comprehesive introduction to the use of PDF::Writer and a simple markup
224
+ language interpreter. PDF::Writer itself only implements a few markup items,
225
+ mostly relating to bold and italic text.
224
226
 
225
227
  PDF::Writer is based on Adobe�s PDF Reference, Fifth Edition, version 1.6.
226
228
  This and earlier editions are available from the
@@ -230,6 +232,29 @@ website</c:alink>. The original implementation was a port of the public
230
232
  domain <c:alink uri="http://www.ros.co.nz/pdf/">R&OS PDF Class for PHP</c:alink>.
231
233
 
232
234
  Other demo programs are available in the <b>demo/</b> directory.
235
+ Alternatively, they may be downloaded separately from the <c:alink
236
+ uri="http://rubyforge.org/projects/ruby-pdf">Ruby PDF Tools</c:alink> project on RubyForge.
237
+
238
+ 2<Installation>
239
+ If this manual was generated from a local installation of PDF::Writer, then
240
+ congratulations! PDF::Writer is installed. Otherwise, you are reading a
241
+ manual generated otherwise. If you want to install PDF::Writer, you can
242
+ download it from the Ruby PDF Tools project on RubyForge or install it with
243
+ RubyGems.
244
+
245
+ PDF::Writer has dependencies on <c:alink
246
+ uri="http://rubyforge.org/frs/?group_id=295&release_id=2130">Transaction::Simple
247
+ 1.3.0</c:alink> or later and <c:alink
248
+ uri="http://rubyforge.org/frs/?group_id=81&release_id=2127">color-tools
249
+ 1.0.0</c:alink> or later. These must be installed for PDF::Writer to work.
250
+ RubyGems installation will automatically detect and offer to download and
251
+ install these dependencies.
252
+
253
+ PDF::Writer is installed with:
254
+
255
+ .code {{{
256
+ % ruby setup.rb
257
+ .endcode }}}
233
258
  .newpage
234
259
  1<Making Documents with PDF::Writer>MakingDocuments
235
260
 
@@ -338,25 +363,24 @@ both the x and y directions. See the following discussion on PDF Coordinate
338
363
  Space for the limitation of performing transformations on the coordinate
339
364
  axis.
340
365
 
366
+ PDF::Writer provides utility methods to convert between normal measurement
367
+ units and and points. These utility methods are available either as class
368
+ mehods or as instance methods.
341
369
  .eval {{{
342
370
  $rm = pdf.right_margin
343
371
  pdf.right_margin += 175
344
372
 
345
- y = pdf.absolute_bottom_margin
373
+ y = pdf.absolute_bottom_margin + 40
346
374
  pdf.stroke_style(PDF::Writer::StrokeStyle.new(1))
347
375
  pdf.rectangle(400, y, 150, 200).stroke
348
376
  x0y0 = "(0, 0)"
349
377
  hh = pdf.font_height(9) + pdf.font_descender(9)
350
- pdf.add_text(405, y + hh - 2, 9, x0y0)
378
+ pdf.add_text(405, y + hh - 2, x0y0, 9)
351
379
  x1y1 = "(150, 200)"
352
- ww = pdf.text_width(9, x1y1)
353
- pdf.add_text(545 - ww, y + 198 - hh, 9, x1y1)
380
+ ww = pdf.text_width(x1y1, 9)
381
+ pdf.add_text(545 - ww, y + 198 - hh, x1y1, 9)
354
382
  .endeval }}}
355
383
 
356
- PDF::Writer provides utility methods to convert between normal measurement
357
- units and and points. These utility methods are available either as class
358
- mehods or as instance methods.
359
-
360
384
  4<PDF::Writer.cm2pts(x)>
361
385
  Converts from centimetres to points.
362
386
 
@@ -378,11 +402,16 @@ pdf.right_margin = $rm
378
402
  PDF::Writer uses the standard coordinate space. Any transformations on the
379
403
  coordinate space (or, more accurately, on the coordinate axis) may affect the
380
404
  usability of PDF::Writer. Standard transformations available against the
381
- coordinate space axis are rotations (clockwise), scaling, translation
405
+ coordinate space axis are rotations (counter-clockwise), scaling, translation
382
406
  (repositioning of the base coordinate) and skew. Each of these will be
383
407
  discussed in more detail in a later section of this manual, after other
384
408
  concepts have been introduced.
385
409
 
410
+ <b>NOTE:</b> As of PDF::Writer 1.1.0, angle rotations are now
411
+ counter-clockwise, not clockwise as in earlier versions. This is a necessary
412
+ incompatible change to make transformations more compatible with other vector
413
+ graphics systems.
414
+
386
415
  2<Fonts, Special Characters, and Character Maps in PDF::Writer>FontBasics
387
416
  All PDF readers support fourteen standard fonts; twelve of these fonts are
388
417
  bold, italic (or oblique), and bold-italic (bold-oblique) variants of three
@@ -492,19 +521,23 @@ The encoding directive will be effective <b>only when the font is first
492
521
  loaded</b>.
493
522
 
494
523
  .code {{{
495
- // use a Times-Roman font with MacExpertEncoding
524
+ # use a Times-Roman font with MacExpertEncoding
496
525
  pdf.select_font("Times-Roman", "MacExpertEncoding")
497
- // this next line should be equivalent
498
- pdf.select_font("Times-Roman", {:encoding=>"MacExpertEncoding"})
499
-
500
- // setup the helvetica font for use with german characters
501
- diff={196=>'Adieresis', 228=>'adieresis',
502
- 214=>'Odieresis', 246=>'odieresis',
503
- 220=>'Udieresis', 252=>'udieresis',
504
- 223=>'germandbls'}
505
- pdf.select_font("Helvetica"
506
- , {:encoding=>"WinAnsiEncoding"
507
- , :differences=>diff})
526
+ # this next line should be equivalent
527
+ pdf.select_font("Times-Roman", { :encoding =&gt; "MacExpertEncoding" })
528
+
529
+ # Set up the Helvetica font for use with German characters as an offset
530
+ # of the WinAnsiEncoding.
531
+ diff= {
532
+ 196 =&gt; 'Adieresis',
533
+ 228 =&gt; 'adieresis',
534
+ 214 =&gt; 'Odieresis',
535
+ 246 =&gt; 'odieresis',
536
+ 220 =&gt; 'Udieresis',
537
+ 252 =&gt; 'udieresis',
538
+ 223 =&gt; 'germandbls'
539
+ }
540
+ pdf.select_font("Helvetica", { :encoding =&gt; "WinAnsiEncoding", :differences => diff })
508
541
  .endcode }}}
509
542
 
510
543
  3<Font Families>FontFamilies
@@ -565,10 +598,11 @@ PDF project, this requirement should be eliminated.
565
598
  4<Embedded Font Licensing Restrictions>
566
599
  As noted above, PDF::Writer will embed Type 1 or TrueType font programs in
567
600
  the PDF document. Fonts are recognised as copyrightable intellectual property
568
- in some jurisdictions. PDF::Writer does not have the ability to check the
569
- licensing rights for these fonts. It is up to the users of this library to
570
- ensure that there are no license violations of any fonts embedded in a PDF
571
- document created with PDF::Writer.
601
+ in some jurisdictions. TrueType fonts encode some licensing rights in the
602
+ font programs and PDF::Writer will check and warn if fonts not licensed for
603
+ inclusion in a document are selected. It is up to the users of PDF::Writer to
604
+ ensure that there are no licence violations of fonts embedded in the
605
+ generated PDF documents.
572
606
 
573
607
  3<Special Characters, Character Maps, and Unicode>SpecialCharacters
574
608
  Fonts in PDF documents can include encoding information. The PDF standard
@@ -606,6 +640,10 @@ values are the characters
606
640
  the font and therefore require additional information to present and space
607
641
  these characters properly.
608
642
 
643
+ #TODO
644
+ As of PDF::Writer version 1.1, these difference maps will be inserted into
645
+ the PDF documents as well. This change is experimental but should be safe.
646
+
609
647
  4<Unicode>
610
648
  PDF supports UTF-16BE encoding of strings�but each such string must begin
611
649
  with the UTF-16BE byte order mark (BOM) of U+FEFF (0xFE followed by 0xFF).
@@ -821,7 +859,9 @@ name="ColumnOutput" label="title" />
821
859
 
822
860
  5<Text Size>
823
861
  If the <b>:font_size</b> is not specified, then the last font size
824
- or the default font size of 12 points will be used.
862
+ or the default font size of 12 points will be used. If this value is
863
+ provided, this <b>changes</b> the current font size just as if the #font_size
864
+ attribute were set.
825
865
 
826
866
  .code {{{
827
867
  pdf.text("Ruby is fun!", :font_size =&gt; 16)
@@ -892,7 +932,7 @@ return <b>true</b> if the text will be overflowed to a new page or column.
892
932
  Text can also be placed starting with specific X and Y coordinates using
893
933
  either <b>PDF::Writer#add_text_wrap</b> or <b>PDF::Writer#add_text</b>.
894
934
 
895
- 4<PDF::Writer#add_text_wrap(x, y, width, size, text, justification = :left, angle = 0, test = false)>
935
+ 4<PDF::Writer#add_text_wrap(x, y, width, text, size = nil, justification = :left, angle = 0, test = false)>
896
936
  This will add text to the page at position <b>(x, y)</b>, but ensures that it
897
937
  fits within the provided <b>width</b>. If it does not fit, then as much as
898
938
  possible will be written using the wrapping rules on page <r:xref
@@ -900,9 +940,13 @@ name="TextWrapping" label="page" />. The remaining text to be written will be
900
940
  returned to the caller.
901
941
 
902
942
  .code {{{
903
- rest = pdf.add_text_wrap(150, pdf.y, 150, 72, "Ruby is fun!")
943
+ rest = pdf.add_text_wrap(150, pdf.y, 150, "Ruby is fun!", 72)
904
944
  .endcode }}}
905
945
 
946
+ If <b>size</b> is not specified, the current #font_size will be used. This
947
+ parameter has changed position with <b>text</b> in PDF::Writer 1.1. If your
948
+ code appears to be using the old parameter call, it will be warned.
949
+
906
950
  The optional justification parameter works just as described on page <r:xref
907
951
  name="TextJustification" label="page" />, except that instead of margin
908
952
  width, it is the boundaries defined by the <b>x</b> and <b>width</b>
@@ -914,33 +958,34 @@ Text may be drawn at an angle. This will be discussed fully in the section on
914
958
  If the <b>test</b> parameter is <b>true</b>, the text will not be written,
915
959
  but the remainder of the text will be returned.
916
960
 
917
- 4<PDF::Writer#add_text(x, y, size, text, angle = 0, word_space_adjust = 0)>
961
+ 4<PDF::Writer#add_text(x, y, text, size = nil, angle = 0, word_space_adjust = 0)>
918
962
  This places the full text string at the <b>(x, y)</b> position and the
919
- specified <b>angle</b> (measured in degrees of a circle, in a clockwise
920
- direction) with respect to the angle of the coordinate axis.
963
+ specified <b>angle</b> (measured in degrees of a circle, in a
964
+ counter-clockwise direction) with respect to the angle of the coordinate
965
+ axis.
966
+
967
+ <b>NOTE:</b> As of PDF::Writer 1.1.0, angle rotations are now
968
+ counter-clockwise, not clockwise as in earlier versions. This is a necessary
969
+ incompatible change to make transformations more compatible with other vector
970
+ graphics systems.
971
+
972
+ If <b>size</b> is not specified, the current #font_size will be used. This
973
+ parameter has changed position with <b>text</b> in PDF::Writer 1.1. If your
974
+ code appears to be using the old parameter call, it will be warned.
921
975
 
922
976
  .code {{{
923
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 0�", 0)
924
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 45�", 45)
925
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 90�", 90)
926
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 135�", 135)
927
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 180�", 180)
928
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 225�", 225)
929
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 270�", 270)
930
- pdf.add_text(pdf.margin_x_middl, pdf.y, 12, " 305�", 305)
977
+ 0.step(315, 45) do |angle|
978
+ pdf.add_text(pdf.margin_x_middle, pdf.y, "#{angle}�".rjust(8), 12,
979
+ angle)
980
+ end
931
981
  .endcode }}}
932
982
  .eval {{{
933
983
  x = pdf.margin_x_middle
934
984
  y = pdf.y - 50
935
985
 
936
- pdf.add_text(x, y, 12, " 0�", 0)
937
- pdf.add_text(x, y, 12, " 45�", 45)
938
- pdf.add_text(x, y, 12, " 90�", 90)
939
- pdf.add_text(x, y, 12, " 135�", 135)
940
- pdf.add_text(x, y, 12, " 180�", 180)
941
- pdf.add_text(x, y, 12, " 225�", 225)
942
- pdf.add_text(x, y, 12, " 270�", 270)
943
- pdf.add_text(x, y, 12, " 305�", 305)
986
+ 0.step(315, 45) do |angle|
987
+ pdf.add_text(x, y, "#{angle}�".rjust(8), 12, angle)
988
+ end
944
989
 
945
990
  pdf.y = y - 30
946
991
  .endeval }}}
@@ -1291,27 +1336,36 @@ appends a page number; it is implemented and used in
1291
1336
  <b>PDF::TechBook::TagTocDots</b>. It is of limited configurability in this
1292
1337
  version.
1293
1338
 
1294
- 5<&lt;r:xref name="XREFNAME" label="page|label"&gt;>
1339
+ 5<&lt;r:xref name="XREFNAME" label="page|label" text="TEXT"/&gt;>
1295
1340
  This replacement callback returns an internal link (&lt;c:ilink...&gt;) with
1296
1341
  either the name (label="title") or the page number (label="page") of the
1297
- cross-reference. The page number will only be used if it is known at the time
1298
- that the &lt;r:xref&gt; tag is processed; forward cross-references will
1299
- always use the label. This is implemented through
1300
- <b>PDF::TechBook::TagXref</b>.
1342
+ cross-reference, or an indicator for arbitrary text (label="text") drawn from
1343
+ the text attribute (e.g., text="random text here"). The page number will only
1344
+ be used if it is known at the time that the &lt;r:xref&gt; tag is processed;
1345
+ forward cross-references will always use the text (if present) or the label.
1346
+ This is implemented through <b>PDF::TechBook::TagXref</b>.
1301
1347
 
1302
1348
  3<Text Height and Width>
1349
+ These methods return the height of the font or the width of the
1350
+ text.
1303
1351
 
1304
- 4<PDF::Writer#font_height(font_size)>
1352
+ 4<PDF::Writer#font_height(font_size = nil)>
1305
1353
  Returns the height of the current font for the given size, measured in PDF
1306
1354
  userspace units. This is the distance from the bottom of the descender to the
1307
- top of the capitals or ascenders.
1355
+ top of the capitals or ascenders. Uses the current #font_size if size is not
1356
+ provided.
1308
1357
 
1309
- 4<PDF::Writer#font_descender(font_size)>
1358
+ 4<PDF::Writer#font_descender(font_size = nil)>
1310
1359
  Returns the size of the descender�the distance below the baseline of the
1311
- font�which will normally be a negative number.
1360
+ font�which will normally be a negative number. Uses the current #font_size if
1361
+ size is not provided.
1312
1362
 
1313
- 4<PDF::Writer#text_width(font_size, text)>
1314
- Returns the width of the given text string at the given font size.
1363
+ 4<PDF::Writer#text_width(text, font_size = nil)>
1364
+ 4<PDF::Writer#text_line_width(text, font_size = nil)>
1365
+ Returns the width of the given text string at the given font size using the
1366
+ current font, or the current default font size if none is given. The
1367
+ difference between #text_width and #text_line_width is that the former will
1368
+ give the width of the largest line in a multiline string.
1315
1369
 
1316
1370
  2<Document Margins and Page Dimensions>DocumentMargins
1317
1371
  A document canvas should not be written from edge to edge in most cases;
@@ -1756,10 +1810,9 @@ is not turned on.
1756
1810
  It is common in documents to see items repeated from page to page. These may
1757
1811
  be watermarks, headers, footers, or other elements that must appear on
1758
1812
  multiple pages�aside from page numbering. PDF::Writer supports this through a
1759
- mechanism called �loose objects.�
1760
-
1761
- 3<Loose Objects>
1813
+ mechanism called �loose content objects.�
1762
1814
 
1815
+ 3<Loose Content Objects>
1763
1816
  Up until this point, a page has been presented as the only canavas available
1764
1817
  to write and draw upon. This is a useful fiction, but it <i>is</i> a fiction.
1765
1818
  Any contents object may be drawn upon, and an implicit contents object is
@@ -1769,28 +1822,30 @@ and should only be written to with explicit locations, as #text is not aware
1769
1822
  of non-page canvases.
1770
1823
 
1771
1824
  4<PDF::Writer#open_object>
1772
- Make a loose object. Output will go into this object until it is closed. This
1773
- object will not appear until it is included within a page. The method will
1774
- return the object reference. To aid in the conceptual grouping of
1775
- modifications to a loose object, this method will yield the opened object if
1776
- a block is provided.
1825
+ Makes a loose content object. Output will go into this object until it is
1826
+ closed. This object will not appear until it is included within a page. The
1827
+ method will return the object reference. To aid in the conceptual grouping of
1828
+ modifications to a loose content object, this method will yield the opened
1829
+ object if a block is provided.
1777
1830
 
1778
1831
  4<PDF::Writer#reopen_object(id)>
1779
1832
  Makes the object for current content insertion the object specified by
1780
1833
  <b>id</b>, which is a value returned by either #open_object or #new_page.
1781
1834
 
1782
1835
  4<PDF::Writer#close_object>
1783
- Closes the currently open loose object, preventing further writing against
1784
- the object.
1836
+ Closes the currently open loose content object, preventing further writing
1837
+ against the object.
1785
1838
 
1786
- 3<Using Loose Objects>
1787
-
1788
- Once a loose object has been created, it must be added
1839
+ 3<Using Loose Content Objects>
1840
+ Once a loose contents object has been created, it must be added to the
1841
+ collection of loose objects before it can be seen in the PDF document.
1842
+ PDF::Writer makes it easy to write these objects to the contents of pages
1843
+ when the pages are created.
1789
1844
 
1790
1845
  4<PDF::Writer#add_object(id, where = :this_page)>
1791
- After a loose object has been created, it will only show if it has been added
1792
- to a page or page(s) with this method. Where the loose object will be added
1793
- is controlled by the <b>where</b> option.
1846
+ After a loose content object has been created, it will only show if it has
1847
+ been added to a page or page(s) with this method. Where the loose content
1848
+ object will be added is controlled by the <b>where</b> option.
1794
1849
 
1795
1850
  The object will not be added to itself.
1796
1851
 
@@ -1808,7 +1863,6 @@ The object will not be added to itself.
1808
1863
  Stops adding the specified object to pages <i>after</i> this page.
1809
1864
 
1810
1865
  3<Example>
1811
-
1812
1866
  The following example is used to create the heading of this manual.
1813
1867
 
1814
1868
  .code {{{
@@ -1819,10 +1873,10 @@ pdf.open_object do |heading|
1819
1873
 
1820
1874
  s = 6
1821
1875
  t = "PDF::Writer for Ruby ~ Manual"
1822
- w = pdf.text_width(s, t) / 2.0
1876
+ w = pdf.text_width(t, s) / 2.0
1823
1877
  x = pdf.margin_x_middle
1824
1878
  y = pdf.absolute_top_margin
1825
- pdf.add_text(x - w, y, s, t)
1879
+ pdf.add_text(x - w, y, t, s)
1826
1880
 
1827
1881
  x = pdf.absolute_left_margin
1828
1882
  w = pdf.absolute_right_margin
@@ -1891,8 +1945,7 @@ viewport is set to <b>top</b>.
1891
1945
  Fits the page vertically to the bounding box of the page. The left of the
1892
1946
  viewport is set to <b>left</b>.
1893
1947
 
1894
- 3<PDF::Writer#add_internal_link(label, x0, y0, x1, y1)>
1895
-
1948
+ 3<PDF::Writer#add_internal_link(label, x0, y0, x1, y1)>internal_links
1896
1949
  Creates an internal link in the document, �label� is the name of an target
1897
1950
  point, and the other settings are the coordinates of the enclosing rectangle
1898
1951
  of the clickable area from <b>(x0, y0)</b> to <b>(x1, y1)</b>.
@@ -1901,8 +1954,7 @@ Note that the destination markers are created using the #add_destination
1901
1954
  method described below. This the manual way of doing what &lt;c:ilink&gt;
1902
1955
  does.
1903
1956
 
1904
- 3<PDF::Writer#add_link(uri, x0, y0, x1, y1)>
1905
-
1957
+ 3<PDF::Writer#add_link(uri, x0, y0, x1, y1)>external_links
1906
1958
  Creates a clickable rectangular area from <b>(x0, y0)</b> to <b>(x1, y1)</b>
1907
1959
  within the current page of the document, which takes the user to the
1908
1960
  specified URI when clicked. This is the manual way of doing what
@@ -1934,7 +1986,6 @@ the way that text is rendered.
1934
1986
  3<#text_render_style(style)>
1935
1987
  3<#text_render_style!(style)>
1936
1988
  3<#text_render_style?>
1937
-
1938
1989
  The first and second methods will set the text rendering style; the second
1939
1990
  forces the style to be set in the PDF document even if it�s the same as the
1940
1991
  currently known text rendering style. The third method returns the current
@@ -1957,7 +2008,7 @@ clipping paths at this point.
1957
2008
  .endblist }}}
1958
2009
 
1959
2010
  .eval {{{
1960
- pdf.move_pointer(200, true)
2011
+ pdf.move_pointer(160, true)
1961
2012
  y = pdf.y + 90
1962
2013
 
1963
2014
  pdf.select_font "Times-Roman"
@@ -1970,12 +2021,13 @@ pdf.rectangle(pdf.absolute_left_margin, y + 64, pdf.margin_width, -100).fill_str
1970
2021
  pdf.fill_color Color::Black
1971
2022
 
1972
2023
  (0..7).each do |style|
1973
- pdf.add_text(pdf.absolute_left_margin + 20 + (60 * style), y + 48, 12, style.to_s)
2024
+ pdf.add_text(pdf.absolute_left_margin + 20 + (60 * style), y + 48,
2025
+ style.to_s, 12)
1974
2026
  end
1975
2027
 
1976
2028
  (0..7).each do |style|
1977
2029
  pdf.text_render_style!(style)
1978
- pdf.add_text(pdf.absolute_left_margin + 5 + (60 * style), y, 64, "Q")
2030
+ pdf.add_text(pdf.absolute_left_margin + 5 + (60 * style), y, "Q", 64)
1979
2031
  end
1980
2032
  .endeval }}}
1981
2033
  .newpage
@@ -2828,8 +2880,7 @@ document.
2828
2880
  Images are inserted into PDF documents as one pixel per PDF userspace unit,
2829
2881
  making a 320�240 image approximately 4���3�� (113mm�85mm) in size.
2830
2882
 
2831
- 3<#add_image(image, x, y, width = nil, height = nil, image_info = nil)>
2832
-
2883
+ 3<#add_image(image, x, y, width = nil, height = nil, image_info = nil, link = nil)>
2833
2884
  Adds an image to the PDF document. The image must be a String that represents
2834
2885
  the binary contents of a PNG or JPEG file <i>or</i> it must be a PDF image
2835
2886
  that has previously been inserted by one of the image insertion methods
@@ -2849,14 +2900,22 @@ If both width and height are specified, the set values will be used.
2849
2900
  If the width and/or height values are negative, the image will be flipped
2850
2901
  horizontally or vertically, as appropriate.
2851
2902
 
2852
- The last parameter, <b>image_info</b>, must either be unspecified or a valid
2903
+ The <b>image_info</b> parameter must either be unspecified, nil, or a valid
2853
2904
  instance of PDF::Writer::Graphics::ImageInfo (see �<r:xref name="ImageInfo"
2854
2905
  label="title" />�).
2855
2906
 
2856
- The image object will be returned so that it can be used again in the future.
2907
+ The <b>link</b> parameter allows the image to be made as a clickable link to
2908
+ internal or external targets. It must be specified as a hash with two
2909
+ options:
2857
2910
 
2858
- 3<#add_image_from_file(image, x, y, width = nil, height = nil)>
2911
+ .blist {{{
2912
+ <b>:type</b> is the type of the link, either <b>:internal</b> or <b>:external</b>. This affects the interpretation of <b>:target</b>.
2913
+ <b>:target</b> is the destination of the link. For <b>:type =&gt; :internal</b> links, this is an internal destination. For <b>:type =&gt; :external</b> links, this is an URI. See <r:xref name="internal_links" label="text" text="#add_internal_link" /> and <r:xref name="external_links" label="text" text="#add_link" /> for more information.
2914
+ .endblist }}}
2859
2915
 
2916
+ The image object will be returned so that it can be used again in the future.
2917
+
2918
+ 3<#add_image_from_file(image, x, y, width = nil, height = nil, link = nil)>
2860
2919
  Adds an image to the PDF document from a file. The <b>image</b> parameter may
2861
2920
  be an IO-like object (it must respond to #read and return the full image data
2862
2921
  in a single read) or a filename. If <i>open-uri</i> is active, the filename
@@ -2865,7 +2924,6 @@ may also be an URI to a remote image.
2865
2924
  In all other ways, it behaves just like #add_image.
2866
2925
 
2867
2926
  3<#image(image, options = {})>
2868
-
2869
2927
  This third method for inserting images into a PDF document holds much the
2870
2928
  same relationship to #add_image and #add_image_from_file as #text holds to
2871
2929
  the text insertion methods #add_text and #add_text_wrap. This method will
@@ -2919,6 +2977,16 @@ border. The parameter may also be a hash with two values.
2919
2977
  <b>:style</b> specifies the stroke style of the border.
2920
2978
  .endblist }}}
2921
2979
 
2980
+ 4<:link>
2981
+ The image may be made a clickable link to internal or external targets. This
2982
+ option must be specified as a hash with two options:
2983
+
2984
+ .blist {{{
2985
+ <b>:type</b> is the type of the link, either <b>:internal</b> or <b>:external</b>. This affects the interpretation of <b>:target</b>.
2986
+ <b>:target</b> is the destination of the link. For <b>:type =&gt; :internal</b> links, this is an internal destination. For <b>:type =&gt; :external</b> links, this is an URI. See <r:xref name="internal_links" label="text" text="#add_internal_link" /> and <r:xref name="external_links" label="text" text="#add_link" /> for more information.
2987
+ .endblist }}}
2988
+
2989
+ 3<Limitations>
2922
2990
  Because #text and #image comprise a <i>simple</i> layout engine, the
2923
2991
  limitations of these methods must be understood. The image will be inserted
2924
2992
  and text will be inserted after it. There is no option to place the image and
@@ -2933,12 +3001,13 @@ left-hand corner of the canvas. PDF::Writer
2933
3001
  behaviour, but the axis can be transformed in several ways. It can be
2934
3002
  translated, rotated, scaled, and skewed.
2935
3003
 
2936
- Axis transformations are cumulative within a graphics state stack level (see
2937
- the next section). It is recommended that axis transformations are performed
2938
- within a #save_state/#restore_state combination.
3004
+ Axis transformations are cumulative (matrix multiplicative; see the
3005
+ description of #transform_matrix for a full explanation) within a graphics
3006
+ state stack level (see the next section). It is recommended that axis
3007
+ transformations are performed within a #save_state/#restore_state
3008
+ combination.
2939
3009
 
2940
3010
  3<translate_axis(x, y)>
2941
-
2942
3011
  Translates the coordinate space so that <b>(x, y)</b> under the old
2943
3012
  coordinate space is now <b>(0, 0)</b>. The <i>direction</i> of the old
2944
3013
  coordinate space is unchanged (y values are increasing). The example code
@@ -2949,12 +3018,15 @@ pdf.translate_axis(pdf.margin_x_middle, pdf.margin_y_middle)
2949
3018
  .endcode }}}
2950
3019
 
2951
3020
  3<rotate_axis(angle)>
3021
+ The entire coordinate space is rotated by the specified angle in a
3022
+ counter-clockwise direction.
2952
3023
 
2953
- The entire coordinate space is rotated by the specified angle in a clockwise
2954
- direction.
3024
+ <b>NOTE:</b> As of PDF::Writer 1.1.0, angle rotations are now
3025
+ counter-clockwise, not clockwise as in earlier versions. This is a necessary
3026
+ incompatible change to make transformations more compatible with other vector
3027
+ graphics systems.
2955
3028
 
2956
3029
  3<scale_axis(x = 1, y = 1)>
2957
-
2958
3030
  Changes the size of PDF userspace units. This changes the scale of all
2959
3031
  operations in PDF documents. With <b>#scale_axis(0.5, 1)</b>, the x-axis is
2960
3032
  modified so that PDF userspace units are 1/144� in width, instead of the
@@ -2965,10 +3037,98 @@ If the scale value is negative, the coordinate axis is reversed and graphics
2965
3037
  or text will be drawn in reverse.
2966
3038
 
2967
3039
  3<skew_axis(xangle = 0, yangle = 0)>
2968
-
2969
3040
  Rotates the x and y axes independently of one another, creating a skewed
2970
3041
  appearance.
2971
3042
 
3043
+ 3<transform_matrix(a, b, c, d, e, f)>
3044
+ Transforms the coordinate axis with the transformation vector interpreted as
3045
+ a coordinate transformation matrix:
3046
+
3047
+ .eval {{{
3048
+ def bracket(pdf, x, y, width, height, size)
3049
+ y -= (height / 1.75)
3050
+ tw = pdf.text_width("[", size * 4)
3051
+ pdf.add_text(x - tw, y, "[", size * 4)
3052
+ tw = pdf.text_width("]", size * 3)
3053
+ pdf.add_text(x + width - tw, y, "]", size * 4)
3054
+ x + width + tw
3055
+ end
3056
+
3057
+ rowh = pdf.font_height(14)
3058
+
3059
+ pdf.move_pointer(rowh * 5, true)
3060
+
3061
+ mw = pdf.text_width("MMMM", 14)
3062
+ _x = pdf.margin_x_middle - (mw / 2.0)
3063
+ _y = pdf.y + (rowh * 3)
3064
+
3065
+ pdf.add_text(_x, _y + rowh, "a c e", 14)
3066
+ pdf.add_text(_x, _y, "b d f", 14)
3067
+ pdf.add_text(_x, _y - rowh, "0 0 1", 14)
3068
+ bracket(pdf, _x, _y, mw, rowh, 14)
3069
+
3070
+ pdf.move_pointer(rowh)
3071
+ .endeval }}}
3072
+
3073
+ The matrix transforms the new coordinates (x1, y1) to the old coordinates
3074
+ (x0, y0) through the dot product:
3075
+
3076
+ .eval {{{
3077
+ def bracket(pdf, x, y, width, height, size)
3078
+ y -= (height / 1.75)
3079
+ tw = pdf.text_width("[", size * 4)
3080
+ pdf.add_text(x - tw, y, "[", size * 4)
3081
+ tw = pdf.text_width("]", size * 3)
3082
+ pdf.add_text(x + width - tw, y, "]", size * 4)
3083
+ x + width + tw
3084
+ end
3085
+
3086
+ rowh = pdf.font_height(14)
3087
+ mtxw = pdf.text_width("MM", 14)
3088
+
3089
+ pdf.move_pointer(rowh * 5, true)
3090
+ _y = pdf.y + (rowh * 3)
3091
+
3092
+ _x = 100
3093
+ pdf.add_text(_x, _y + rowh, "x0", 14)
3094
+ pdf.add_text(_x, _y, "y0", 14)
3095
+ pdf.add_text(_x, _y - rowh, " 1", 14)
3096
+ _x = bracket(pdf, _x, _y, mtxw, rowh, 14)
3097
+
3098
+ pdf.add_text(_x, _y - (rowh / 1.5), '=', 42)
3099
+
3100
+ mtxw = pdf.text_width("MMMM", 14)
3101
+ _x += mtxw
3102
+
3103
+ pdf.add_text(_x, _y + rowh, "a c e", 14)
3104
+ pdf.add_text(_x, _y, "b d f", 14)
3105
+ pdf.add_text(_x, _y - rowh, "0 0 1", 14)
3106
+ _x = bracket(pdf, _x, _y, mtxw, rowh, 14)
3107
+
3108
+ pdf.circle_at(_x - 3, _y + 3, 3).fill
3109
+
3110
+ mtxw = pdf.text_width("MM", 14)
3111
+ _x += mtxw
3112
+
3113
+ pdf.add_text(_x, _y + rowh, "x1", 14)
3114
+ pdf.add_text(_x, _y, "y1", 14)
3115
+ pdf.add_text(_x, _y - rowh, " 1", 14)
3116
+ bracket(pdf, _x, _y, mtxw, rowh, 14)
3117
+
3118
+ pdf.move_pointer(rowh)
3119
+ .endeval }}}
3120
+
3121
+ In practice, the six variables (a�f) be represented as a six-element vector:
3122
+ [ a b c d e f ].
3123
+
3124
+ .blist {{{
3125
+ Axis translation uses [ 1 0 0 1 x y ] where x and y are the new (0,0) coordinates in the old axis system.
3126
+ Scaling uses [ sx 0 0 sy 0 0 ] where sx and sy are the scaling factors.
3127
+ Rotation uses [ cos(a) sin(a) -sin(a) cos(a) 0 0 ] where a is the angle, measured in radians.
3128
+ X axis skewing uses [ 1 0 tan(a) 1 0 0 ] where a is the angle, measured in radians.
3129
+ Y axis skewing uses [ 1 tan(a) 0 1 0 0 ] where a is the angle, measured in radians.
3130
+ .endblist }}}
3131
+
2972
3132
  2<Graphics State>
2973
3133
  PDF allows for multiple independent levels of graphics state to be saved in a
2974
3134
  last-in first-out stack. Graphics states may not remain open over page
@@ -3039,9 +3199,11 @@ Indicates or sets document compression. If the value is true, the document
3039
3199
  will be compressed on writing using the �deflate� compression method. If the
3040
3200
  �zlib� library cannot be loaded, compression settings will be ignored.
3041
3201
 
3202
+ <b>NOTE:</b> This value should be set as early as possible during the
3203
+ document generation, or only some sections of the PDF will be compressed.
3204
+
3042
3205
  3<PDF::Writer#media_box(x0, y0, x1, y1)>
3043
3206
  3<PDF::Writer#trim_box(x0, y0, x1, y1)>
3044
-
3045
3207
  The #trim_box and the #media_box are both expressed in default (unscaled)
3046
3208
  user space units. The #media_box defines the boundaries of the physical
3047
3209
  medium on which the page is intended to be displayed or printed. As of this
@@ -3099,7 +3261,6 @@ A name object indicating whether the document has been modified to include
3099
3261
  trapping information. This is not currently supported by PDF::Writer.
3100
3262
 
3101
3263
  3<PDF::Writer#viewer_preferences(label, value = 0)>
3102
-
3103
3264
  This will set values that indicate to the viewer how it should display the
3104
3265
  itself with respect to this document.
3105
3266
 
@@ -3160,7 +3321,6 @@ value of +style+ affects the interpretation of +params+.
3160
3321
  PDF::Writer#open_here uses the current page as the starting location.
3161
3322
 
3162
3323
  3<PDF::Writer#encrypt(user_pass = nil, owner_pass = nil, permissions = [])>
3163
-
3164
3324
  Encrypts the document using Adobe RC4. This will set the user and owner
3165
3325
  passwords that will be used to access the document and set the permissions
3166
3326
  the user has with the document. The passwords are limited to 32 characters.
@@ -3191,6 +3351,10 @@ printing and copy/paste operations.
3191
3351
  .code {{{
3192
3352
  pdf.encrypt('trees', 'frogs', [ :copy, :print ])
3193
3353
  .endcode }}}
3354
+
3355
+ 3<PDF::Writer#save_as(filename)>
3356
+ Saves the PDF document as a file to disk.
3357
+
3194
3358
  .newpage
3195
3359
  1<Tables in PDF Documents>TablesInPDF
3196
3360
 
@@ -3222,7 +3386,6 @@ elements (required and optional), text options, border and shading options,
3222
3386
  positioning options, and pagination opitons.
3223
3387
 
3224
3388
  3<PDF::SimpleTable.new>
3225
-
3226
3389
  This creates a SimpleTable with default values. It will yield the created
3227
3390
  table if a block is provided.
3228
3391
 
@@ -3237,7 +3400,6 @@ end
3237
3400
  .endcode }}}
3238
3401
 
3239
3402
  3<Structural Elements>
3240
-
3241
3403
  A SimpleTable cannot render itself if it does not know what columns are to be
3242
3404
  displayed or if it does not have any data. Thus, #data and #column_order must
3243
3405
  be defined before the table rendering code will work. Optionally, options can
@@ -3373,7 +3535,6 @@ Sets this table cell heading to be rendered bold. Independent of the
3373
3535
  table-wide #bold_headings setting.
3374
3536
 
3375
3537
  3<Text Options>
3376
-
3377
3538
  These options control the display of the text in and around the table.
3378
3539
 
3379
3540
  4<SimpleTable#title, SimpleTable#title=>
@@ -3407,7 +3568,6 @@ The text colour of the body cells. Defaults to Color::Black.
3407
3568
  Makes the heading text bold if <b>true</b>. The default is <b>false</b>.
3408
3569
 
3409
3570
  3<Border and Shading Options>
3410
-
3411
3571
  These options control the appearance of the borders (if shown) and row
3412
3572
  shading (if enabled).
3413
3573
 
@@ -3456,7 +3616,6 @@ Defines the inner and outer line styles. The default style for both is
3456
3616
  PDF::Writer::StrokeStyle::DEFAULT.
3457
3617
 
3458
3618
  3<Positioning Options>
3459
-
3460
3619
  These options control how and where the table, or some elements of a table,
3461
3620
  will be positioned. All measurements here are in normal PDF userspace units.
3462
3621
 
@@ -3550,7 +3709,6 @@ The space added to the bottom of each row between the text and the lines of
3550
3709
  the cell. Default: 2 units.
3551
3710
 
3552
3711
  3<Pagination Options>
3553
-
3554
3712
  These options tell SimpleTable what to do when the table crosses a page
3555
3713
  boundary. All measurements here are in PDF userspace units.
3556
3714
 
@@ -3575,7 +3733,6 @@ typically used for a repeating text header or other similar items. Default: 0
3575
3733
  units.
3576
3734
 
3577
3735
  3<Drawing the Table>
3578
-
3579
3736
  The table is drawn with the #render_on method.
3580
3737
 
3581
3738
  4<SimpleTable#render_on(pdf)>
@@ -3600,7 +3757,6 @@ table.data = [
3600
3757
  .endcode }}}
3601
3758
 
3602
3759
  3<Basic Table>
3603
-
3604
3760
  This table shows the �row,� �name,� and �race� columns with default settings.
3605
3761
 
3606
3762
  .code {{{
@@ -3648,7 +3804,6 @@ end
3648
3804
  .endeval }}}
3649
3805
 
3650
3806
  3<Table with Custom Column Headings>
3651
-
3652
3807
  This table creates custom column headings for display. For completeness�
3653
3808
  sake, a title has been added to the table.
3654
3809
 
@@ -3691,7 +3846,6 @@ end
3691
3846
  .endeval }}}
3692
3847
 
3693
3848
  3<No Headings, Shadings, or Lines>
3694
-
3695
3849
  This table isn�t quite the same as the one above. Close, though. Sort of.
3696
3850
 
3697
3851
  .code {{{
@@ -3740,7 +3894,6 @@ end
3740
3894
  .endeval }}}
3741
3895
 
3742
3896
  3<Controlled Width and Positioning>
3743
-
3744
3897
  A version of the table with an explicitly too-small width, forcing content to
3745
3898
  wrap. This table is positioned at the right margin and oriented to the left
3746
3899
  of the right margin.
@@ -3909,7 +4062,6 @@ R&amp;OS PDF class. It has been adapted to PDF::Writer with some improvements
3909
4062
  in configurability and capability.
3910
4063
 
3911
4064
  3<PDF::Charts::StdDev.new>
3912
-
3913
4065
  This will create the standard deviation chart with default values. If a block
3914
4066
  is provided, the created chart will be yielded.
3915
4067
 
@@ -4193,11 +4345,10 @@ and 6 are matched. This will use a Z-fold that places columns 5 and 6 face to
4193
4345
  face and columns 2 and 3 face to face. In the folded reference sheet, columns
4194
4346
  1 and 4 will be facing out. The illustrations below are useful for
4195
4347
  understanding this.
4196
-
4197
4348
  .eval {{{
4198
- pdf.move_pointer(200, true)
4349
+ pdf.move_pointer(150, true)
4199
4350
 
4200
- _y = pdf.y + 190
4351
+ _y = pdf.y + 140
4201
4352
 
4202
4353
  pdf.save_state
4203
4354
  pdf.stroke_color! Color::Black
@@ -4207,17 +4358,17 @@ pdf.rectangle(100, _y, 75, -50).line(125, _y, 125, _y - 50)
4207
4358
  pdf.line(150, _y, 150, _y - 50).stroke
4208
4359
 
4209
4360
  pdf.fill_color Color::Grey60
4210
- pdf.add_text(105, _y - 36, 36, "1")
4211
- pdf.add_text(130, _y - 36, 36, "2")
4212
- pdf.add_text(155, _y - 36, 36, "3")
4361
+ pdf.add_text(105, _y - 36, "1", 36)
4362
+ pdf.add_text(130, _y - 36, "2", 36)
4363
+ pdf.add_text(155, _y - 36, "3", 36)
4213
4364
 
4214
4365
  pdf.rectangle(215, _y - 15, 25, -50).stroke
4215
- pdf.add_text(220, _y - 51, 36, "3")
4366
+ pdf.add_text(220, _y - 51, "3", 36)
4216
4367
  pdf.line(225, _y, 215, _y - 15).line(225, _y - 50, 215, _y - 65).stroke
4217
4368
  pdf.fill_color Color::White
4218
4369
  pdf.rectangle(200, _y, 25, -50).fill_stroke
4219
4370
  pdf.fill_color Color::Grey60
4220
- pdf.add_text(205, _y - 36, 36, "1")
4371
+ pdf.add_text(205, _y - 36, "1", 36)
4221
4372
 
4222
4373
  pdf.fill_color Color::Black
4223
4374
  pdf.line(200, _y + 5, 225, _y + 5).stroke
@@ -4229,9 +4380,8 @@ pdf.move_to(218, _y - 70).line_to(225, _y - 67.5).line_to(225, _y - 72.5)
4229
4380
  pdf.close_fill
4230
4381
  pdf.restore_state
4231
4382
 
4232
- pdf.move_pointer(-90)
4383
+ pdf.move_pointer(-60)
4233
4384
  .endeval }}}
4234
-
4235
4385
  2<Brochures>
4236
4386
  Brochures differ in their design and intent than a reference sheet. A common
4237
4387
  brochure is also three columns (although parts of a brochure�especially
@@ -4247,10 +4397,9 @@ brochure will be folded so that columns 2 and 3 are face to face. After this,
4247
4397
  column 1 will face column 4 (exposed by the first fold). In the folded
4248
4398
  brochure, columns 5 and 6 are facing out. The illustrations below are useful
4249
4399
  for understanding this.
4250
-
4251
4400
  .eval {{{
4252
- pdf.move_pointer(200, true)
4253
- _y = pdf.y + 190
4401
+ pdf.move_pointer(150, true)
4402
+ _y = pdf.y + 140
4254
4403
  pdf.save_state
4255
4404
 
4256
4405
  pdf.stroke_color! Color::Black
@@ -4259,16 +4408,16 @@ pdf.rectangle(100, _y, 75, -50).line(125, _y, 125, _y - 50)
4259
4408
  pdf.line(150, _y, 150, _y - 50).stroke
4260
4409
 
4261
4410
  pdf.fill_color Color::Grey60
4262
- pdf.add_text(103, _y - 36, 36, "1")
4263
- pdf.add_text(128, _y - 36, 36, "2")
4264
- pdf.add_text(153, _y - 36, 36, "3")
4411
+ pdf.add_text(103, _y - 36, "1", 36)
4412
+ pdf.add_text(128, _y - 36, "2", 36)
4413
+ pdf.add_text(153, _y - 36, "3", 36)
4265
4414
 
4266
4415
  pdf.rectangle(225, _y, 25, -50)
4267
4416
  pdf.line(220, _y + 10, 220, _y - 40).line(220, _y + 10, 225, _y)
4268
4417
  pdf.line(220, _y - 40, 225, _y - 50)
4269
4418
  pdf.line(255, _y + 10, 255, _y - 40).line(255, _y + 10, 250, _y)
4270
4419
  pdf.line(255, _y - 40, 250, _y - 50).stroke
4271
- pdf.add_text(228, _y - 36, 36, "2")
4420
+ pdf.add_text(228, _y - 36, "2", 36)
4272
4421
 
4273
4422
  pdf.save_state
4274
4423
  pdf.fill_color Color::Black
@@ -4280,7 +4429,7 @@ pdf.restore_state
4280
4429
  pdf.rectangle(325, _y, 25, -50)
4281
4430
  pdf.line(320, _y + 10, 320, _y - 40).line(320, _y + 10, 325, _y)
4282
4431
  pdf.line(320, _y - 40, 325, _y - 50).stroke
4283
- pdf.add_text(328, _y - 36, 36, "4")
4432
+ pdf.add_text(328, _y - 36, "4", 36)
4284
4433
  pdf.save_state
4285
4434
  pdf.line(300, _y - 60, 325, _y - 60).stroke
4286
4435
  pdf.fill_color Color::Black
@@ -4289,12 +4438,11 @@ pdf.close_fill
4289
4438
  pdf.restore_state
4290
4439
 
4291
4440
  pdf.rectangle(425, _y, 25, -50).stroke
4292
- pdf.add_text(428, _y - 36, 36, "6")
4441
+ pdf.add_text(428, _y - 36, "6", 36)
4293
4442
  pdf.restore_state
4294
4443
 
4295
- pdf.move_pointer(-90)
4444
+ pdf.move_pointer(-60)
4296
4445
  .endeval }}}
4297
-
4298
4446
  2<Using PDF::QuickRef>
4299
4447
  PDF::QuickRef implements a domain-specific language (DSL) for creating
4300
4448
  reference sheets or brochures. It is intended to flow from column 1 to column
@@ -4326,7 +4474,6 @@ operations.
4326
4474
  3<QuickRef#title_font, QuickRef#title_font=>
4327
4475
  3<QuickRef#title_font_encoding, QuickRef#title_font_encoding=>
4328
4476
  3<QuickRef#title_font_size, QuickRef#title_font_size=>
4329
-
4330
4477
  The name, encoding, and size of the font that will be used when drawing
4331
4478
  title text with #title. The default font is Times-Roman 14 point with the
4332
4479
  standard �WinAnsiEncoding� encoding.
@@ -4337,7 +4484,6 @@ standard
4337
4484
  3<QuickRef#h2_font_size, QuickRef#h2_font_size=>
4338
4485
  3<QuickRef#h3_font_size, QuickRef#h3_font_size=>
4339
4486
  3<QuickRef#h4_font_size, QuickRef#h4_font_size=>
4340
-
4341
4487
  The name, encoding, and size of the font that will be used when drawing
4342
4488
  heading text with #h1, #h2, #h3, or #h4. The default font is Times-Roman with
4343
4489
  �WinAnsiEncoding� as the encoding. #h1 defaults to 11 points; #h2 to 9
@@ -4348,7 +4494,6 @@ points, #h3 to 8 points, and #h4 to 7 points.
4348
4494
  3<QuickRef#body_font_encoding, QuickRef#body_font_encoding=>
4349
4495
  3<QuickRef#code_font_encoding, QuickRef#code_font_encoding=>
4350
4496
  3<QuickRef#body_font_size, QuickRef#body_font_size=>
4351
-
4352
4497
  Text drawn with #body, #lines, and #pairs will be drawn with the #body_font
4353
4498
  using #body_font_encoding at #body_font_size. Text drawn with #pre,
4354
4499
  #codelines, and #codepairs will be drawn with the #code_font using
@@ -4358,14 +4503,12 @@ default. The default #body_font_size is 7 points.
4358
4503
 
4359
4504
  3<QuickRef#pairs(text)>
4360
4505
  3<QuickRef#codepairs(text)>
4361
-
4362
4506
  Creates a two-column shaded table using #body_font (#pairs) or #code_font
4363
4507
  (#codepairs). Each line of the text is a separate row. The two columns are
4364
4508
  separated by tab characters.
4365
4509
 
4366
4510
  3<QuickRef#lines(text)>
4367
4511
  3<QuickRef#codelines(text)>
4368
-
4369
4512
  Creates a one-column shaded table using #body_font (#pairs) or #code_font
4370
4513
  (#codepairs). Each line of the text is a separate row.
4371
4514
 
@@ -4402,7 +4545,7 @@ Writes code text. Newlines and spaces will be preserved.
4402
4545
  Draws a horizontal line with the specified style and colour across the width
4403
4546
  of the column.
4404
4547
 
4405
- 3<QuickRef#save_as(filename, compressed = true)>
4548
+ 3<QuickRef#save_as(filename)>
4406
4549
  Writes the Quick Reference to disk.
4407
4550
 
4408
4551
  3<QuickRef#render, QuickRef#to_s>
@@ -4421,6 +4564,274 @@ PDF::QuickRef.make do # 3-column LETTER
4421
4564
  save_as "MyQuickRef.pdf"
4422
4565
  end
4423
4566
  .endcode }}}
4567
+ .newpage
4568
+ 1<PDF::TechBook>
4569
+
4570
+ The TechBook class is a markup language interpreter. This will read a file
4571
+ containing the �TechBook� markukp, described below, and create a PDF document
4572
+ from it. This is intended as a complete document language, but it does have a
4573
+ number of limitations.
4574
+
4575
+ The TechBook markup language and class are used to format the PDF::Writer
4576
+ manual, represented in the distrubtion by the file �manual.pwd�.
4577
+
4578
+ The TechBook markup language is <b>primarily</b> stream-oriented with
4579
+ awareness of lines. That is to say that the document will be read and
4580
+ generated from beginning to end in the order of the markup stream.
4581
+
4582
+ 2<TechBook Markup>
4583
+ TechBook markup is relatively simple. The simplest markup is no markup at all
4584
+ (flowed paragraphs). This means that two lines separated by a single line
4585
+ separator will be treaed as part of the same paragraph and formatted
4586
+ appropriately by PDF::Writer. Paragaphs are terminated by empty lines, valid
4587
+ line markup directives, or valid headings.
4588
+
4589
+ Certain XML entitites will need to be escaped as they would in normal XML
4590
+ usage, that is, �&lt;� must be written as �&amp;lt;�; �&gt;� must be written
4591
+ as �&amp;gt;�; and �&amp;� must be written as �&amp;amp;�.
4592
+
4593
+ Comments, headings, and directives are line-oriented where the first
4594
+ mandatory character is in the first column of the document and take up the
4595
+ whole line. Styling and callback tags may appear anywhere in the text.
4596
+
4597
+ 3<Comments>
4598
+ Comments begin with the hash-mark (�#�) at the beginning of the line. Comment
4599
+ lines are ignored.
4600
+
4601
+ 3<Styling and Callback Tags>
4602
+ Within normal, preserved, or code text, or in headings, HTML-like markup may
4603
+ be used for bold (�&lt;b&gt;�) and italic (�&lt;i&gt;�) text. TechBook
4604
+ supports standard PDF::Writer callback tags (&lt;c:alink&gt;,
4605
+ &lt;c:ilink&gt;, &lt;C:bullet/&gt;, and &lt;C:disc/&gt;) and adds two new
4606
+ ones (&lt;r:xref/&gt;, &lt;C:tocdots/&gt;). See �<r:xref name="TextTags"
4607
+ label="label" />� for more information.
4608
+
4609
+ 3<Directives>
4610
+ Directives begin with a period (�.�) and are followed by a letter (�a�..�z�)
4611
+ and then any combination of word characters (�a�..�z�, �0�..�9�, and �_�).
4612
+ Directives are case-insensitive. A directive may have arguments; if there are
4613
+ arguments, they must follow the directive name after whitespace. After the
4614
+ arguments for a directive, if any, all other text is ignored and may be
4615
+ considered a comment.
4616
+
4617
+ 4<<b>.newpage [force]</b>>
4618
+ The <b>.newpage</b> directive starts a new page. If multicolumn mode is on, a
4619
+ new column will be started if the current column is not the last column. If
4620
+ the optional argument <b>force</b> follows the <b>.newpage</b> directive, a
4621
+ new page will be started even if multicolumn mode is on.
4622
+
4623
+ .code {{{
4624
+ .newpage
4625
+ .newpage force
4626
+ .endcode }}}
4627
+
4628
+ 4<<b>.pre</b>, <b>.endpre</b>>
4629
+ The <b>.pre</b> and <b>.endpre</b> directives enclose a block of text with
4630
+ preserved newlines. This is similar to normal text, but the lines in the
4631
+ <b>.pre</b> block are not flowed together. This is useful for poetic forms or
4632
+ other text that must end when each line ends. <b>.pre</b> blocks may not be
4633
+ nested in any other formatting block. When an <b>.endpre</b> directive is
4634
+ encountered, the text format will be returned to normal (flowed text) mode.
4635
+
4636
+ .code {{{
4637
+ .pre
4638
+ The Way that can be told of is not the eternal Way;
4639
+ The name that can be named is not the eternal name.
4640
+ The Nameless is the origin of Heaven and Earth;
4641
+ The Named is the mother of all things.
4642
+ Therefore let there always be non-being,
4643
+ so we may see their subtlety,
4644
+ And let there always be being,
4645
+ so we may see their outcome.
4646
+ The two are the same,
4647
+ But after they are produced,
4648
+ they have different names.
4649
+ .endpre
4650
+ .endcode }}}
4651
+
4652
+ This will look like the following:
4653
+
4654
+ .pre {{{
4655
+ The Way that can be told of is not the eternal Way;
4656
+ The name that can be named is not the eternal name.
4657
+ The Nameless is the origin of Heaven and Earth;
4658
+ The Named is the mother of all things.
4659
+ Therefore let there always be non-being,
4660
+ so we may see their subtlety,
4661
+ And let there always be being,
4662
+ so we may see their outcome.
4663
+ The two are the same,
4664
+ But after they are produced,
4665
+ they have different names.
4666
+ .endpre }}}
4667
+
4668
+ 4<<b>.code</b>, <b>.endcode</b>>
4669
+ The <b>.code</b> and <b>.endcode</b> directives enclose a block of text with
4670
+ preserved newlines. In addition, the font is changed from the normal
4671
+ #techbook_textfont to #techbook_codefont. The #techbook_codefont is normally
4672
+ a fixed pitched font and defaults to Courier. At the end of the code block,
4673
+ the text state is restored to its prior state, which will either be
4674
+ <b>.pre</b> or normal.
4675
+
4676
+ .code {{{
4677
+ .code
4678
+ require 'pdf/writer'
4679
+ PDF::Writer.prepress # US Letter, portrait, 1.3, prepress
4680
+ .endcode
4681
+ .endcode }}}
4682
+
4683
+ 4<<b>.blist</b>, <b>.endblist</b>>
4684
+ These directives enclose a bulleted list block. Lists may be nested within
4685
+ other text states. If lists are nested, each list will be appropriately
4686
+ indented. Each line in the list block will be treated as a single list item
4687
+ with a bullet inserted in front using either the &lt;C:bullet/&gt; or
4688
+ &lt;C:disc/&gt; callbacks. Nested lists are successively indented.
4689
+ <b>.blist</b> directives accept one optional argument, the name of the type
4690
+ of bullet callback desired (e.g., �bullet� for &lt;C:bullet/&gt; and �disc�
4691
+ for &lt;C:disc/&gt;).
4692
+
4693
+ .code {{{
4694
+ .blist
4695
+ Item 1
4696
+ .blist disc
4697
+ Item 1.1
4698
+ .endblist
4699
+ .endblist
4700
+ .endcode }}}
4701
+
4702
+ 4<<b>.eval</b>, <b>.endeval</b>>
4703
+ With these directives, the block enclosed will collected and passed to Ruby�s
4704
+ Kernel#eval. <b>.eval</b> blocks may be present within normal text,
4705
+ <b>.pre</b>, <b>.code</b>, and <b>.blist</b> blocks. No other block may be
4706
+ embedded within an <b>.eval</b> block.
4707
+
4708
+ .code {{{
4709
+ .eval
4710
+ puts "Hello"
4711
+ .endeval
4712
+ .endcode }}}
4713
+
4714
+ 4<<b>.columns</b>>
4715
+ Multi-column output is controlled with this directive, which accepts one or
4716
+ two parameters. The first parameter is mandatory and is either the number of
4717
+ columns (2 or more) or the word �off� (turning off multi-column output). When
4718
+ starting multi-column output, a second parameter with the gutter size may be
4719
+ specified.
4720
+
4721
+ .code {{{
4722
+ .columns 3
4723
+ Column 1
4724
+ .newpage
4725
+ Column 2
4726
+ .newpage
4727
+ Column 3
4728
+ .columns off
4729
+ .endcode }}}
4730
+
4731
+ 4<<b>.toc [TITLE]</b>>
4732
+ This directive is used to tell TechBook to generate a table of contents after
4733
+ the first page (assumed to be a title page). If this is not present, then a
4734
+ table of contents will not be generated. The title of the table of contents
4735
+ can be provided after this directive.
4736
+
4737
+ 4<<b>.author</b>, <b>.title</b>, <b>.subject</b>, <b>.keywords</b>>
4738
+ Sets values in the PDF information object. The arguments�to the end of the
4739
+ line�are used to populate the values.
4740
+
4741
+ 4<<b>.done</b>>
4742
+ Stops the processing of the document at this point.
4743
+
4744
+ 3<Headings>
4745
+ Headings begin with a number followed by the rest of the heading format. This
4746
+ format is �#&lt;heading-text&gt;� or �#&lt;heading-text&gt;xref_name�.
4747
+ TechBook supports five levels of headings. Headings may include markup, but
4748
+ should not exceed a single line in size; those headings which have boxes as
4749
+ part of their layout are not currently configured to work with multiple lines
4750
+ of heading output. If an xref_name is specified, then the &lt;r:xref/&gt; tag
4751
+ can use this name to find the target for the heading. If xref_name is not
4752
+ specified, then the �name� associated with the heading is the index of the
4753
+ order of insertion. The xref_name is case sensitive.
4754
+
4755
+ .code {{{
4756
+ 1<Chapter>xChapter
4757
+ 2<Section>Section23
4758
+ 3<Subsection>
4759
+ 4<Subsection>
4760
+ 5<Subsection>
4761
+ .endcode }}}
4762
+
4763
+ 4<Heading Level 1>
4764
+ First level headings are generally chapters. As such, the standard
4765
+ implementation of the heading level 1 method (#__heading1), will be rendered
4766
+ as �chapter#. heading-text� in centered white on a black background, at 26
4767
+ point (H1_STYLE). First level headings are added to the table of contents.
4768
+
4769
+ 4<Heading Level 2>
4770
+ Second level headings are major sections in chapters. The headings are
4771
+ rendered by default as black on 80% grey, left-justified at 18 point
4772
+ (H2_STYLE). The text is unchanged (#__heading2). Second level headings are
4773
+ added to the table of contents.
4774
+
4775
+ 4<Heading Level 3, 4, and 5>
4776
+ The next three heading levels are used for varying sections within second
4777
+ level chapter sections. They are rendered by default in black on the
4778
+ background (there is no bar) at 18, 14, and 12 points, respectively
4779
+ (H3_STYLE, H4_STYLE, and H5_STYLE). Third level headings are bold-faced
4780
+ (#__heading3); fourth level headings are italicised (#__heading4), and fifth
4781
+ level headings are underlined (#__heading5).
4782
+
4783
+ 2<Configuring TechBook>
4784
+ TechBook is reasonably configurable. Formatting options may be changed with
4785
+ methods in the techbook object. Text transformations and directives must be
4786
+ done either as a subclass of TechBook or by reopening the TechBook class.
4787
+
4788
+ 3<Formatting Options>
4789
+ These options are configurable as a client and can be configured within the
4790
+ document source with an .eval directive.
4791
+
4792
+ 4<#techbook_codefont>
4793
+ 4<#techbook_textfont>
4794
+ 4<#techbook_encoding>
4795
+ 4<#techbook_fontsize>
4796
+ These values configure the fonts and encoding for TechBook documents.
4797
+
4798
+ 3<Code Extensions>
4799
+
4800
+ # TBD
4801
+
4802
+ 2<techbook Command>
4803
+ The TechBook class is also available with a command-line program, techbook
4804
+ (bin/techbook). The command-line interface is:
4805
+
4806
+ .code {{{
4807
+ Usage: techbook [options] [INPUT FILE]
4808
+ INPUT FILE, if not specified, will be 'manual.pwd', either in the
4809
+ current directory or relative to this file.
4810
+
4811
+ -f, --force-regen Forces the regeneration of the document,
4812
+ ignoring the cached document version.
4813
+ -n, --no-cache Disables generated document caching.
4814
+ -z, --compress Compresses the resulting PDF.
4815
+
4816
+ --help Shows this text.
4817
+ .endcode }}}
4818
+
4819
+ 3<--no-cache>
4820
+ By default, the techbook command will generate the PDF document and a cached
4821
+ version of the document. If the input file is �test.pwd�, then both
4822
+ �test.pdf� and �test._mc� will be generated. This can be disabled by using
4823
+ the <b>--no-cache</b> option.
4824
+
4825
+ 3<--force-regen>
4826
+ If the input file is older than the generated cache document (if one exists),
4827
+ then techbook command will regenerate the document from the input file. This
4828
+ option forces this regeneration.
4829
+
4830
+ 3<--compress>
4831
+ The document will not be compressed by default. This option will compress the
4832
+ document. This can <em>only</em> be applied if the document is being
4833
+ generated from the original document, not the cached document.
4834
+
4424
4835
  .newpage
4425
4836
  1<PDF::Writer Dependencies>
4426
4837
 
@@ -4552,7 +4963,6 @@ v.transaction_open? # -> false
4552
4963
  .endcode }}}
4553
4964
 
4554
4965
  3<Grouped Transactions>
4555
-
4556
4966
  .code {{{
4557
4967
  require 'transaction/simple/group'
4558
4968
 
@@ -4588,8 +4998,10 @@ y = -> "And you, too."
4588
4998
  .endcode }}}
4589
4999
 
4590
5000
  3<Methods>
5001
+ These are the methods that objects extended with Transaction::Simple will
5002
+ know.
4591
5003
 
4592
- 4<#transaction_open?(name = nil)
5004
+ 4<#transaction_open?(name = nil)>
4593
5005
  Returns <b>true</b> if a transaction is currently open if the <em>name</em>
4594
5006
  parameter is <b>nil</b>. If a name is requested, then returns <b>true</b> if
4595
5007
  a transaction with that name is currently open.
@@ -4673,7 +5085,7 @@ must be understood. Transaction::Simple:
4673
5085
  �does not necessarily maintain Object#__id__ values on rewind or abort. This may change for future versions that will be Ruby 1.8 or better <b>only</b>. Certain objects that support #replace will maintain Object#__id__.
4674
5086
  �can be a memory hog if you use many levels of transactions on many objects.
4675
5087
  .endblist }}}
4676
-
5088
+ .newpage
4677
5089
  2<color-tools>ColorTools
4678
5090
  The color-tools package was created to abstract out the colour needs for
4679
5091
  PDF::Writer and make them available for other uses as well (such as web
@@ -4911,7 +5323,15 @@ Loops through the palette
4911
5323
  .newpage
4912
5324
  1<PDF::Writer Demos>
4913
5325
 
4914
- A quick overview of the demo programs and what they are expected to do.
5326
+ A quick overview of the demo programs and what they are expected to do. These
5327
+ may be downloaded separately from the main PDF::Writer package at the
5328
+ RubyForge project for PDF::Writer.
5329
+
5330
+ If PDF::Writer has been installed with RubyGems, then the demos will need to
5331
+ be run explicitly referencing RubyGems:
5332
+ .code {{{
5333
+ % ruby -rubygems chunkybacon.rb
5334
+ .endcode }}}
4915
5335
 
4916
5336
  2<chunkybacon.rb>
4917
5337
  Creates a single-page document with three copies of an image from <i>Why�s
@@ -4953,21 +5373,50 @@ original text.
4953
5373
  .newpage
4954
5374
  1<Future Plans>
4955
5375
 
5376
+ There are great plans for future versions of PDF::Writer.
5377
+
4956
5378
  .blist {{{
4957
5379
  Support for Text::Hyphen hyphenation in text wrapping methods.
4958
5380
  Widow/orphan support (so that paragraphs never have less than two lines on a page).
4959
5381
  First line indent, hanging indent.
4960
5382
  More chart types: pie chart, bar chart, line chart.
4961
- Sparklines (inline, text-sized charts, first described by Malcolm Gladwell).
5383
+ Sparklines (inline, text-sized charts, first described by Edward Tufte).
4962
5384
  Drop-caps.
4963
5385
  In-line font changes, such as &lt;c:code&gt;.
4964
5386
  Slideshows (both plain PDF and SVG).
4965
5387
  Event detection: callbacks on page change, etc. This will be necessary to support multiple page sizes and orientations within a single document.
5388
+ Support for code page maps; these are predefined encodings and encoding difference sets.
5389
+ Unicode support�at least UTF-16.
4966
5390
  .endblist }}}
4967
5391
  .newpage
4968
5392
  1<Revision History>
4969
5393
 
5394
+ 2<Version 1.1.0: June 29, 2005>
5395
+ <b>NOTE</b>: The first two changes are <em>incompatible</em> with previous
5396
+ versions of PDF::Writer. A 90� angle in the PDF::Writer 1.0.x must be
5397
+ represented as a -90� (or 270�) angle in PDF::Writer 1.1 or later.
5398
+
5399
+ .blist {{{
5400
+ Axis transformations in PDF::Writer::Graphics have been fixed.
5401
+ Text axis transformation in PDF::Writer#add_text has been fixed.
5402
+ Changed #text_width and #text_line_width so that the text value is the first parameter and the size parameter is second and optional. The code warns about it now, but it will break in PDF::Writer 2.0.
5403
+ Changed #add_text and #add_text_wrap so that the text parameter is before the now-optional size parameter. The code warns about it now, but it will break in PDF::Writer 2.0.
5404
+ Added #transform_matrix.
5405
+ Fixed compression. <b>NOTE</b>: Compression must be set early in the documentation process, or only some items will be compressed in the document. The various #save_as methods have been changed to reflect this fact.
5406
+ Enabled the placement of encoding differences dictionaries in the resulting PDF document. This change should be considered experimental.
5407
+ Added TTF licence checking. The embedding of a file not licenced for inclusion in a document will continue, but a warning will be output to standard error. This code has been gakked from FPDF (http://www.fpdf.org).
5408
+ Properly supporting symbolic font flags now.
5409
+ Added the ability to make images clickable links with any of the three image insertion methods.
5410
+ .endblist }}}
5411
+
4970
5412
  2<Version 1.0.1: June 13, 2005>
5413
+ .blist {{{
5414
+ Fixed a few minor gem issues.
5415
+ Renamed bin/manual to bin/techbook.
5416
+ Fixed the manual.pwd locator for the default install.
5417
+ Added support and documentation for a separately downloadable demo package.
5418
+ Expanded the installation documentation.
5419
+ .endblist }}}
4971
5420
 
4972
5421
  2<Version 1.0.0: June 12, 2005>
4973
5422
  .blist {{{
@@ -5026,7 +5475,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5026
5475
  SOFTWARE.
5027
5476
 
5028
5477
  3<Works Included Under Other Licences>
5029
- 4<lib/pdf/writer/graphics/imageinfo.rb>
5478
+ 4<pdf/writer/graphics/imageinfo.rb>
5030
5479
  PDF::Writer includes a derivative of Keisuke Minami�s ImageSize library,
5031
5480
  which can be found at
5032
5481
  <c:alink uri="http://www.rubycgi.org/tools/index.en.htm">rubycgi</c:alink>.
@@ -5049,14 +5498,13 @@ Ruby
5049
5498
  Commons Attributions ShareAlike</c:alink> licence.
5050
5499
 
5051
5500
  4<Adobe PostScript AFM Files>
5052
- The file �lib/pdf/writer/fonts/MustRead.html� and the 14 PostScript� AFM
5053
- files it accompanies may be used, copied, and distributed for any purpose and
5054
- without charge, with or without modification, provided that all copyright
5055
- notices are retained; that the AFM files are not distributed without this
5056
- file; that all modifications to this file or any of the AFM files are
5057
- prominently noted in the modified file(s); and that this paragraph is not
5058
- modified. Adobe Systems has no responsibility or obligation to support the
5059
- use of the AFM files.
5501
+ The file �pdf/writer/fonts/MustRead.html� and the 14 PostScript� AFM files it
5502
+ accompanies may be used, copied, and distributed for any purpose and without
5503
+ charge, with or without modification, provided that all copyright notices are
5504
+ retained; that the AFM files are not distributed without this file; that all
5505
+ modifications to this file or any of the AFM files are prominently noted in
5506
+ the modified file(s); and that this paragraph is not modified. Adobe Systems
5507
+ has no responsibility or obligation to support the use of the AFM files.
5060
5508
 
5061
5509
  3<Other Credits>
5062
5510
  4<R & OS PDF Class for PDF>
@@ -5065,16 +5513,18 @@ uri="http://www.ros.co.nz/pdf/">R & OS PDF class for PHP</c:alink>, which is
5065
5513
  released as public domain.
5066
5514
 
5067
5515
  4<Standard Deviation Chart>
5068
- The standard deviation chart (lib/pdf/charts/stddev.rb) class is based on
5516
+ The standard deviation chart (pdf/charts/stddev.rb) class is based on
5069
5517
  work by <c:alink uri="mailto:cewing@u.washington.edu">Cris Ewing</c:alink> of
5070
5518
  the University of Washington School of Medicine, originally created for the R
5071
5519
  & OS PDF class for PHP. He has graciously donated the code for PDF::Writer
5072
5520
  for Ruby.
5073
5521
 
5074
- 4<Code Pages and Encoding>
5075
- The code page handling routines are loosely based on routines in FPDF, both
5076
- the <c:alink uri="http://www.fpd.org">PHP</c:alink> and <c:alink
5077
- uri="http://brian.imxcc.com/">Ruby</c:alink> versions.
5522
+ 4<bluesmoke.jpg>
5523
+ The logo image for PDF::Writer, bluesmoke.jpg, is modified from a picture
5524
+ taken by <c:alink uri="mailto:matthewbowden@gmail.com">Matthew "TheSaint"
5525
+ Bowden</c:alink> and is available on the stock.xchng� at <c:alink
5526
+ uri="http://www.sxc.hu/browse.phtml?f=view&id=275430">http://www.sxc.hu/browse.phtml?f=view&id=275430</c:alink>.
5527
+ Many thanks to Matthew for the use of this image.
5078
5528
 
5079
5529
  3<Patents Covering the Adobe PDF Format>
5080
5530
  4<ADOBE PATENTS>
@@ -5146,9 +5596,6 @@ pdf.stop_page_numbering(true, :current)
5146
5596
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
5147
5597
  # for full licensing information.
5148
5598
  #
5149
- # $Id: manual.pwd,v 1.41 2005/06/13 19:32:37 austin Exp $
5599
+ # $Id: manual.pwd,v 1.50 2005/06/29 19:32:07 austin Exp $
5150
5600
  # vim: sts=2 sw=2 ts=4 et ai tw=77 foldmethod=marker foldcolumn=2
5151
5601
  #++
5152
- # Blue Smoke image by Matthew "thesaint" Bowden, <matthewbowden@gmail.com>.
5153
- # http://www.sxc.hu/browse.phtml?f=view&id=275430
5154
- # http://www.sxc.hu/browse.phtml?f=profile&l=thesaint