Skip to content
Browse files

always de-ref the document page count

* just in case it's an indirect object
* thanks to Igor Jorobus for reporting
  • Loading branch information...
1 parent b714fa9 commit f29fa04511a9924562d646d921f81961570567c2 @yob committed
Showing with 18 additions and 5 deletions.
  1. +1 −1 lib/pdf/reader.rb
  2. BIN spec/data/indirect_page_count.pdf
  3. +3 −0 spec/integrity.yml
  4. +14 −4 spec/reader_spec.rb
View
2 lib/pdf/reader.rb
@@ -135,7 +135,7 @@ def metadata
def page_count
pages = @objects.deref(root[:Pages])
- @page_count ||= pages[:Count]
+ @page_count ||= @objects.deref(pages[:Count])
end
def pdf_version
View
BIN spec/data/indirect_page_count.pdf
Binary file not shown.
View
3 spec/integrity.yml
@@ -23,6 +23,9 @@ data/dutch.pdf:
data/encrypted_with_no_user_pass_and_revision_one.pdf:
:bytes: 15674
:md5: 88a9b78341fa55879fa94930bd4d33af
+data/indirect_page_count.pdf:
+ :bytes: 957
+ :md5: a84031df45b2431aabd2ca3107321c08
data/invalid/data.csv:
:bytes: 26
:md5: 7168179491824d651a304cbb83c16964
View
18 spec/reader_spec.rb
@@ -27,12 +27,22 @@
end
describe "page_count()" do
- it "should return the correct page_count" do
- PDF::Reader.new(cairo_basic).page_count.should eql(2)
+ context "with cairo-basic" do
+ it "should return the correct page_count" do
+ PDF::Reader.new(cairo_basic).page_count.should eql(2)
+ end
end
- it "should return the correct page_count" do
- PDF::Reader.new(no_text_spaces).page_count.should eql(6)
+ context "with cairo-basic" do
+ it "should return the correct page_count" do
+ PDF::Reader.new(no_text_spaces).page_count.should eql(6)
+ end
+ end
+
+ context "with indirect_page_count" do
+ it "should return the correct page_count" do
+ PDF::Reader.new(pdf_spec_file("indirect_page_count")).page_count.should eql(1)
+ end
end
end

0 comments on commit f29fa04

Please sign in to comment.
Something went wrong with that request. Please try again.