Permalink
Browse files

Fixes for trunk too

  • Loading branch information...
sandal
sandal committed Dec 13, 2007
1 parent 41bc74f commit a9f9efcd56b43724abb61baa0187f84b1cdcacd7
Showing with 10 additions and 21 deletions.
  1. +1 −2 Rakefile
  2. +9 −7 lib/pdf/writer.rb
  3. +0 −12 test/test_page_numbering.rb
View
@@ -258,5 +258,4 @@ desc "Release the latest version."
task :release => [ :verify_rubyforge, :verify_gmail, :release_files,
:publish_news, :email_announcement, :docs ]
-desc "Build everything."
-task :default => [ :tar, :gem, :demotar, :docs ]
+task :default => [ :test ]
View
@@ -2155,11 +2155,7 @@ def current_page_number
#
# Each time page numbers are started, a new page number scheme will be
# started. The scheme number will be returned.
- def start_page_numbering(x, y, size, pos = nil, pattern = nil, starting = nil)
- if starting
- raise "We have currently disabled starting values for start_page_numbering" +
- " because it is buggy."
- end
+ def start_page_numbering(x, y, size, pos = nil, pattern = nil, starting = nil)
pos ||= :left
pattern ||= "<PAGENUM> of <TOTALPAGENUM>"
starting ||= 1
@@ -2268,6 +2264,7 @@ def add_page_numbers
end
status = nil
+ delta = pattern = pos = x = y = size = nil
pattern = pos = x = y = size = nil
@pageset.each_with_index do |page, index|
@@ -2277,6 +2274,11 @@ def add_page_numbers
if info
if info[:start]
status = true
+ if info[:starting]
+ delta = info[:starting] - index
+ else
+ delta = index
+ end
pattern = info[:pattern]
pos = info[:pos]
@@ -2296,8 +2298,8 @@ def add_page_numbers
if status
# Add the page numbering to this page
- num = index + 1
- total = total_pages
+ num = index + delta.to_i
+ total = total_pages + num - index
patt = pattern.gsub(/<PAGENUM>/, num.to_s).gsub(/<TOTALPAGENUM>/, total.to_s)
reopen_object(page.contents.first)
@@ -10,16 +10,4 @@
@pdf.current_page_number.should == 1
end
- it "should not raise an error when starting value isn't set" do
- assert_nothing_raised do
- @pdf.start_page_numbering(0,0,12, nil, nil)
- end
- end
-
- it "should raise an error when starting is set (disabled due to bugginess" do
- assert_raises(RuntimeError) do
- @pdf.start_page_numbering(0,0,12,nil,nil,1)
- end
- end
-
end

0 comments on commit a9f9efc

Please sign in to comment.