pdf-writer 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/ChangeLog +1 -1
  2. data/LICENCE +9 -3
  3. data/README +1 -1
  4. data/bin/techbook +1 -1
  5. data/demo/chunkybacon.rb +1 -1
  6. data/demo/code.rb +1 -1
  7. data/demo/colornames.rb +1 -1
  8. data/demo/demo.rb +1 -1
  9. data/demo/gettysburg.rb +1 -1
  10. data/demo/hello.rb +1 -1
  11. data/demo/individual-i.rb +1 -1
  12. data/demo/pac.rb +1 -1
  13. data/demo/qr-language.rb +4 -4
  14. data/demo/qr-library.rb +1 -1
  15. data/lib/pdf/charts.rb +1 -1
  16. data/lib/pdf/charts/stddev.rb +2 -2
  17. data/lib/pdf/math.rb +1 -1
  18. data/lib/pdf/quickref.rb +17 -15
  19. data/lib/pdf/simpletable.rb +24 -23
  20. data/lib/pdf/techbook.rb +1 -1
  21. data/lib/pdf/writer.rb +21 -52
  22. data/lib/pdf/writer/arc4.rb +1 -1
  23. data/lib/pdf/writer/fontmetrics.rb +2 -1
  24. data/lib/pdf/writer/fonts/MustRead.html +19 -1
  25. data/lib/pdf/writer/graphics.rb +3 -3
  26. data/lib/pdf/writer/graphics/imageinfo.rb +365 -365
  27. data/lib/pdf/writer/lang.rb +1 -1
  28. data/lib/pdf/writer/lang/en.rb +1 -1
  29. data/lib/pdf/writer/object.rb +1 -1
  30. data/lib/pdf/writer/object/action.rb +1 -1
  31. data/lib/pdf/writer/object/annotation.rb +1 -1
  32. data/lib/pdf/writer/object/catalog.rb +1 -1
  33. data/lib/pdf/writer/object/contents.rb +1 -5
  34. data/lib/pdf/writer/object/destination.rb +1 -1
  35. data/lib/pdf/writer/object/encryption.rb +1 -1
  36. data/lib/pdf/writer/object/font.rb +1 -1
  37. data/lib/pdf/writer/object/fontdescriptor.rb +1 -1
  38. data/lib/pdf/writer/object/fontencoding.rb +1 -1
  39. data/lib/pdf/writer/object/image.rb +1 -5
  40. data/lib/pdf/writer/object/info.rb +3 -7
  41. data/lib/pdf/writer/object/outline.rb +1 -1
  42. data/lib/pdf/writer/object/outlines.rb +1 -1
  43. data/lib/pdf/writer/object/page.rb +1 -1
  44. data/lib/pdf/writer/object/pages.rb +1 -1
  45. data/lib/pdf/writer/object/procset.rb +1 -1
  46. data/lib/pdf/writer/object/viewerpreferences.rb +1 -1
  47. data/lib/pdf/writer/ohash.rb +1 -1
  48. data/lib/pdf/writer/oreader.rb +1 -1
  49. data/lib/pdf/writer/state.rb +1 -1
  50. data/lib/pdf/writer/strokestyle.rb +1 -1
  51. data/manual.pwd +1 -1
  52. metadata +115 -119
  53. data/demo/pagenumber.rb +0 -79
data/ChangeLog CHANGED
@@ -105,6 +105,6 @@
105
105
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
106
106
  # for full licensing information.
107
107
  #
108
- # $Id: ChangeLog,v 1.17.2.4 2005/09/09 12:36:42 austin Exp $
108
+ # $Id: ChangeLog 184 2007-12-10 03:18:48Z sandal $
109
109
  #++
110
110
  # vim: sts=2 sw=2 ts=4 et ai tw=77
data/LICENCE CHANGED
@@ -1,7 +1,13 @@
1
1
  = PDF::Writer for Ruby
2
2
  Homepage:: http://rubyforge.org/projects/ruby-pdf/
3
- Copyright:: Copyright � 2003�2005 Austin Ziegler.
4
- Summary:: MIT-style
3
+ Copyright:: Copyright � 2003�2005 Austin Ziegler.
4
+ Summary:: MIT-style
5
+
6
+ This project had a change of maintainers in November, 2007.
7
+ New developments are now copyrighted by Gregory Brown and Michael Milner,
8
+ unless otherwise noted.
9
+
10
+ ---
5
11
 
6
12
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
13
  of this software and associated documentation files (the "Software"), to deal
@@ -121,5 +127,5 @@ feature for any purpose other than as set forth in the applicable license
121
127
  grant. Adobe has other patents in various fields, none of which are hereby
122
128
  licensed.
123
129
 
124
- $Id: LICENCE,v 1.10 2005/06/29 19:32:07 austin Exp $
130
+ $Id: LICENCE 184 2007-12-10 03:18:48Z sandal $
125
131
  # vim: sts=2 sw=2 ts=4 et ai tw=77
data/README CHANGED
@@ -28,6 +28,6 @@ Transaction::Simple 1.3.0 or better.
28
28
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
29
29
  # for full licensing information.
30
30
  #
31
- # $Id: README,v 1.7.2.1 2005/08/25 03:38:05 austin Exp $
31
+ # $Id: README 184 2007-12-10 03:18:48Z sandal $
32
32
  #++
33
33
  # vim: sts=2 sw=2 ts=4 et ai tw=77
@@ -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,v 1.1 2005/06/13 20:03:53 austin Exp $
10
+ # $Id: techbook 184 2007-12-10 03:18:48Z sandal $
11
11
  #++
12
12
  begin
13
13
  require 'pdf/techbook'
@@ -10,7 +10,7 @@
10
10
  # and are from "Why's (Poignant) Guide to Ruby" at
11
11
  # <http://poignantguide.net/ruby> with permission.
12
12
  #
13
- # $Id: chunkybacon.rb,v 1.7 2005/07/01 16:48:26 austin Exp $
13
+ # $Id: chunkybacon.rb 184 2007-12-10 03:18:48Z sandal $
14
14
  #++
15
15
  begin
16
16
  require 'pdf/writer'
@@ -11,7 +11,7 @@
11
11
  # I'll need to play with the X position some to get it right. This will NOT
12
12
  # make it into the 1.0 release. Maybe 1.1 or 1.2.
13
13
  #
14
- # $Id: code.rb,v 1.3 2005/06/13 19:32:37 austin Exp $
14
+ # $Id: code.rb 184 2007-12-10 03:18:48Z sandal $
15
15
  #++
16
16
  begin
17
17
  require 'pdf/writer'
@@ -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: colornames.rb,v 1.2.2.1 2005/08/25 03:38:05 austin Exp $
9
+ # $Id: colornames.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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.8.2.1 2005/08/25 03:38:05 austin Exp $
9
+ # $Id: demo.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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.5 2005/06/15 21:38:38 austin Exp $
9
+ # $Id: gettysburg.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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: hello.rb,v 1.6 2005/06/13 19:32:37 austin Exp $
9
+ # $Id: hello.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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: individual-i.rb,v 1.4 2005/06/13 19:32:37 austin Exp $
9
+ # $Id: individual-i.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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: pac.rb,v 1.4.2.1 2005/08/25 03:38:05 austin Exp $
9
+ # $Id: pac.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  begin
12
12
  require 'pdf/writer'
@@ -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.14 2005/06/29 19:57:30 austin Exp $
13
+ # $Id: qr-language.rb 184 2007-12-10 03:18:48Z sandal $
14
14
  #++
15
15
  begin
16
16
  require 'pdf/writer'
@@ -42,7 +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
+ # pdf.compressed = true
46
46
  pdf.info.author = "Ryan Davis"
47
47
  pdf.info.title = "Ruby Language Quick Reference"
48
48
  pdf.info.subject = "The Ruby Programming Language"
@@ -167,11 +167,11 @@ variables, and operators.
167
167
  range = RangeThingy.new(lower_bound) .. RangeThingy.new(upper_bound)
168
168
  EOS
169
169
 
170
- h2 "Regexen"
170
+ h2 "Regular Expressions"
171
171
  pre <<-'EOS'
172
172
  /normal regex/[xim]
173
173
  %r|alternate form|[xim]
174
- Regex.new(pattern, options)
174
+ Regexp.new(pattern, options)
175
175
  EOS
176
176
  pairs <<-'EOS'
177
177
  . any character except newline
@@ -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.7 2005/06/29 03:12:11 austin Exp $
13
+ # $Id: qr-library.rb 184 2007-12-10 03:18:48Z sandal $
14
14
  #++
15
15
  begin
16
16
  require 'pdf/writer'
@@ -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: charts.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
9
+ # $Id: charts.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  # A namespace for charts that can be drawn on PDF::Writer canvases.
12
12
  module PDF::Charts
@@ -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.2.2 2005/09/07 17:01:14 austin Exp $
9
+ # $Id: stddev.rb 184 2007-12-10 03:18:48Z sandal $
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.1.3'
23
+ VERSION = '1.1.4'
24
24
 
25
25
  # A data element.
26
26
  DataPoint = Struct.new(:label, :average, :stddev)
@@ -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: math.rb,v 1.3 2005/05/16 20:44:34 austin Exp $
9
+ # $Id: math.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  # Encapsulate some of the mathematical calculations that need to be
12
12
  # performed when working with PDF documents. All angles in PDF::Writer are
@@ -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.10.2.3 2005/09/07 17:01:14 austin Exp $
9
+ # $Id: quickref.rb 184 2007-12-10 03:18:48Z sandal $
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.1.3'
54
+ VERSION = '1.1.4'
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
@@ -62,7 +62,7 @@ class PDF::QuickRef
62
62
  #
63
63
  # After the columns are started, lines will be drawn between column
64
64
  # positions.
65
- def initialize(paper = "LETTER", columns = 3)
65
+ def initialize(paper = "LETTER", columns = 3, column_separators_visible = true)
66
66
  @pdf = PDF::Writer.new(:paper => paper, :orientation => :landscape)
67
67
  @pdf.margins_pt 18
68
68
  @pdf.y = @pdf.absolute_top_margin
@@ -107,20 +107,22 @@ class PDF::QuickRef
107
107
  @ptab.maximum_width = @pdf.column_width - 10
108
108
  @ltab.maximum_width = @pdf.column_width - 10
109
109
 
110
+ if column_separators_visible
110
111
  # Put lines between the columns.
111
- all = @pdf.open_object
112
- @pdf.save_state
113
- @pdf.stroke_color! Color::RGB::Black
114
- @pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
115
- (1 .. (columns - 1)).each do |ii|
116
- x = @pdf.left_margin + (@pdf.column_width * ii)
117
- x += (@pdf.column_gutter * (ii - 0.5))
118
- @pdf.line(x, @pdf.page_height - @pdf.top_margin, x, @pdf.bottom_margin)
119
- @pdf.stroke
112
+ all = @pdf.open_object
113
+ @pdf.save_state
114
+ @pdf.stroke_color! Color::RGB::Black
115
+ @pdf.stroke_style PDF::Writer::StrokeStyle::DEFAULT
116
+ (1 .. (columns - 1)).each do |ii|
117
+ x = @pdf.left_margin + (@pdf.column_width * ii)
118
+ x += (@pdf.column_gutter * (ii - 0.5))
119
+ @pdf.line(x, @pdf.page_height - @pdf.top_margin, x, @pdf.bottom_margin)
120
+ @pdf.stroke
121
+ end
122
+ @pdf.restore_state
123
+ @pdf.close_object
124
+ @pdf.add_object(all, :all_pages)
120
125
  end
121
- @pdf.restore_state
122
- @pdf.close_object
123
- @pdf.add_object(all, :all_pages)
124
126
  end
125
127
 
126
128
  # Access to the raw PDF canvas for normal PDF::Writer configuration.
@@ -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.13.2.2 2005/09/07 17:01:14 austin Exp $
9
+ # $Id: simpletable.rb 184 2007-12-10 03:18:48Z sandal $
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.1.3'
17
+ VERSION = '1.1.4'
18
18
 
19
19
  include Transaction::Simple
20
20
 
@@ -555,7 +555,7 @@ class PDF::SimpleTable
555
555
  mx = 0
556
556
 
557
557
  if @show_headings
558
- hOID = __open_new_object__(pdf) if @shade_headings
558
+ old_y = y
559
559
 
560
560
  pdf.fill_color @heading_color
561
561
  _height, y = __table_column_headings__(pdf, pos, max_width,
@@ -566,12 +566,13 @@ class PDF::SimpleTable
566
566
  y1 = y
567
567
 
568
568
  if @shade_headings
569
- pdf.close_object
570
569
  pdf.fill_color! @shade_heading_color
571
570
  pdf.rectangle(x0 - @gap / 2, y, x1 - x0, _height).fill
572
- pdf.reopen_object(hOID)
573
- pdf.close_object
574
- pdf.restore_state
571
+ pdf.fill_color @heading_color
572
+ __table_column_headings__(pdf, pos, max_width, height,
573
+ descender, @row_gap,
574
+ @heading_font_size, old_y)
575
+ pdf.fill_color @text_color
575
576
  end
576
577
 
577
578
  dm = pdf.absolute_left_margin - base_left_margin
@@ -769,29 +770,29 @@ class PDF::SimpleTable
769
770
 
770
771
  # Find the maximum widths of the text within each column. Default to
771
772
  # zero.
772
- def __find_table_max_width__(pdf)
773
- max_width = PDF::Writer::OHash.new(0)
773
+ def __find_table_max_width__(pdf)
774
+ max_width = PDF::Writer::OHash.new(-1)
774
775
 
775
- # Find the maximum cell widths based on the data and the headings.
776
- # Passing through the data multiple times is unavoidable as we must do
777
- # some analysis first.
776
+ # Find the maximum cell widths based on the data and the headings.
777
+ # Passing through the data multiple times is unavoidable as we must
778
+ # do some analysis first.
778
779
  @data.each do |row|
779
- @cols.each do |name, column|
780
- w = pdf.text_width(row[name].to_s, @font_size)
781
- w *= WIDTH_FACTOR
780
+ @cols.each do |name, column|
781
+ w = pdf.text_width(row[name].to_s, @font_size)
782
+ w *= PDF::SimpleTable::WIDTH_FACTOR
782
783
 
783
- max_width[name] = w if w > max_width[name]
784
- end
784
+ max_width[name] = w if w > max_width[name]
785
+ end
785
786
  end
786
787
 
787
788
  @cols.each do |name, column|
788
- title = column.heading.title if column.heading
789
- title ||= column.name
790
- w = pdf.text_width(title, @heading_font_size)
791
- w *= WIDTH_FACTOR
792
- max_width[name] = w if w > max_width[name]
789
+ title = column.heading.title if column.heading
790
+ title ||= column.name
791
+ w = pdf.text_width(title, @heading_font_size)
792
+ w *= PDF::SimpleTable::WIDTH_FACTOR
793
+ max_width[name] = w if w > max_width[name]
793
794
  end
794
- max_width
795
+ max_width
795
796
  end
796
797
  private :__find_table_max_width__
797
798
 
@@ -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.17.2.1 2005/08/25 03:38:05 austin Exp $
10
+ # $Id: techbook.rb 184 2007-12-10 03:18:48Z sandal $
11
11
  #++
12
12
  require 'pdf/simpletable'
13
13
  require 'pdf/charts/stddev'
@@ -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: writer.rb,v 1.38.2.2 2005/09/07 17:01:14 austin Exp $
9
+ # $Id: writer.rb 184 2007-12-10 03:18:48Z sandal $
10
10
  #++
11
11
  require 'thread'
12
12
  require 'open-uri'
@@ -19,7 +19,7 @@ require 'color'
19
19
  module PDF
20
20
  class Writer
21
21
  # The version of PDF::Writer.
22
- VERSION = '1.1.3'
22
+ VERSION = '1.1.4'
23
23
 
24
24
  # Escape the text so that it's safe for insertion into the PDF
25
25
  # document.
@@ -370,9 +370,8 @@ class PDF::Writer
370
370
  # Initialize the default font families.
371
371
  init_font_families
372
372
 
373
- # Items formerly in EZWriter
374
373
  @font_size = 10
375
- @pageset = []
374
+ @pageset = [@pages.first_page]
376
375
 
377
376
  if paper.kind_of?(Array)
378
377
  if paper.size == 4
@@ -400,7 +399,6 @@ class PDF::Writer
400
399
  @y = absolute_top_margin
401
400
  # Get the ID of the page that was created during the instantiation
402
401
  # process.
403
- @pageset[1] = @pages.first_page
404
402
 
405
403
  fill_color! Color::RGB::Black
406
404
  stroke_color! Color::RGB::Black
@@ -697,38 +695,6 @@ class PDF::Writer
697
695
  :add => 32
698
696
  }
699
697
 
700
- # Encrypts the document. This will set the user and owner passwords that
701
- # will be used to access the document and set the permissions the user
702
- # has with the document. The passwords are limited to 32 characters.
703
- #
704
- # The permissions provided are an array of symbols, allowing identified
705
- # users to perform particular actions:
706
- # <tt>:print</tt>:: Print.
707
- # <tt>:modify</tt>:: Modify text or objects.
708
- # <tt>:copy</tt>:: Copy text or objects.
709
- # <tt>:add</tt>:: Add text or objects.
710
- def encrypt(user_pass = nil, owner_pass = nil, permissions = [])
711
- perms = ["11000000"].pack("B8")
712
-
713
- permissions.each do |perm|
714
- perms += ENCRYPT_OPTIONS[perm] if ENCRYPT_OPTIONS[perm]
715
- end
716
-
717
- @arc4 ||= PDF::ARC4.new
718
- owner_pass ||= user_pass
719
-
720
- options = {
721
- :owner_pass => owner_pass,
722
- :user_pass => user_pass,
723
- :permissions => perms,
724
- }
725
- @encryption = PDF::Writer::Object::Encryption.new(self, options)
726
- end
727
-
728
- def encrypted?
729
- not @encryption.nil?
730
- end
731
-
732
698
  # should be used for internal checks, not implemented as yet
733
699
  def check_all_here
734
700
  end
@@ -743,7 +709,7 @@ class PDF::Writer
743
709
 
744
710
  xref = []
745
711
 
746
- content = "%PDF-#{@version}\n%����\n"
712
+ content = "%PDF-#{@version}\n%âãÏÓ\n"
747
713
  pos = content.size
748
714
 
749
715
  objects.each do |oo|
@@ -2186,12 +2152,14 @@ class PDF::Writer
2186
2152
  # number of pages in the page numbering scheme. The default +pattern+ is
2187
2153
  # "<PAGENUM> of <TOTALPAGENUM>".
2188
2154
  #
2189
- # If +starting+ is non-nil, this is the first page number. The number of
2190
- # total pages will be adjusted to account for this.
2191
2155
  #
2192
2156
  # Each time page numbers are started, a new page number scheme will be
2193
2157
  # started. The scheme number will be returned.
2194
- def start_page_numbering(x, y, size, pos = nil, pattern = nil, starting = nil)
2158
+ def start_page_numbering(x, y, size, pos = nil, pattern = nil)
2159
+ if starting
2160
+ raise "We have currently disabled starting values for start_page_numbering" +
2161
+ " because it is buggy."
2162
+ end
2195
2163
  pos ||= :left
2196
2164
  pattern ||= "<PAGENUM> of <TOTALPAGENUM>"
2197
2165
  starting ||= 1
@@ -2279,7 +2247,7 @@ class PDF::Writer
2279
2247
  def add_page_numbers
2280
2248
  # This will go through the @page_numbering array and add the page
2281
2249
  # numbers are required.
2282
- if @page_numbering
2250
+ if @page_numbering
2283
2251
  page_count = @pageset.size
2284
2252
  pn_tmp = @page_numbering.dup
2285
2253
 
@@ -2288,10 +2256,10 @@ class PDF::Writer
2288
2256
  # First, find the total pages for this schemes.
2289
2257
  page = page_number_search(:stop_total, scheme)
2290
2258
 
2291
- if page
2259
+ if page
2292
2260
  total_pages = page
2293
2261
  else
2294
- page = page_number_search(:stop_total_next, scheme)
2262
+ page = page_number_search(:stop_total_next, scheme)
2295
2263
  if page
2296
2264
  total_pages = page
2297
2265
  else
@@ -2300,7 +2268,7 @@ class PDF::Writer
2300
2268
  end
2301
2269
 
2302
2270
  status = nil
2303
- delta = pattern = pos = x = y = size = nil
2271
+ pattern = pos = x = y = size = nil
2304
2272
 
2305
2273
  @pageset.each_with_index do |page, index|
2306
2274
  next if status.nil? and scheme[index].nil?
@@ -2309,11 +2277,6 @@ class PDF::Writer
2309
2277
  if info
2310
2278
  if info[:start]
2311
2279
  status = true
2312
- if info[:starting]
2313
- delta = info[:starting] - index
2314
- else
2315
- delta = index
2316
- end
2317
2280
 
2318
2281
  pattern = info[:pattern]
2319
2282
  pos = info[:pos]
@@ -2333,8 +2296,8 @@ class PDF::Writer
2333
2296
 
2334
2297
  if status
2335
2298
  # Add the page numbering to this page
2336
- num = index + delta.to_i
2337
- total = total_pages + num - index
2299
+ num = index + 1
2300
+ total = total_pages
2338
2301
  patt = pattern.gsub(/<PAGENUM>/, num.to_s).gsub(/<TOTALPAGENUM>/, total.to_s)
2339
2302
  reopen_object(page.contents.first)
2340
2303
 
@@ -2783,5 +2746,11 @@ class PDF::Writer
2783
2746
  # Save the PDF as a file to disk.
2784
2747
  def save_as(name)
2785
2748
  File.open(name, "wb") { |f| f.write self.render }
2749
+ end
2750
+
2751
+ # memory improvement for transaction-simple
2752
+ def _post_transaction_rewind
2753
+ @objects.each { |e| e.instance_variable_set(:@parent,self) }
2786
2754
  end
2755
+
2787
2756
  end