jpdfer 0.2.0 → 0.3.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.
@@ -1,3 +1,4 @@
1
+ require 'jpdfer/page_sizes'
1
2
  # High-level/convenience wrapper class for a PDF document.
2
3
 
3
4
  module Jpdfer
@@ -90,6 +91,22 @@ module Jpdfer
90
91
  end
91
92
  end
92
93
 
94
+ # Returns the page size of the pdf as [width (Float), height (Float)]
95
+ def page_size
96
+ page_size = @stamper.reader.crop_box(1)
97
+ if @stamper.reader.page_rotation(1) % 180 == 0
98
+ [page_size.width, page_size.height]
99
+ else
100
+ [page_size.height, page_size.width]
101
+ end
102
+ end
103
+
104
+ # Returns the page type of the pdf or :unknown
105
+ # See Jpdfer::PAGES_SIZES
106
+ def page_type
107
+ PAGE_SIZES.fetch(page_size, :unknown)
108
+ end
109
+
93
110
  # Returns fields defined in this PDF form and their values, if any.
94
111
  # fields returns an empty hash if PDF document does not contain a form
95
112
  def fields
@@ -1,3 +1,3 @@
1
1
  module Jpdfer
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -128,6 +128,18 @@ describe "Pdf Acceptance" do
128
128
  end
129
129
  end
130
130
 
131
+ describe '#page_size' do
132
+ it 'should return the page size as an array of floats' do
133
+ @pdf.page_size.should == [612.0, 792.0]
134
+ end
135
+ end
136
+
137
+ describe '#page_type' do
138
+ it 'should return the page type if it exists' do
139
+ @pdf.page_type.should == :letter
140
+ end
141
+ end
142
+
131
143
  describe '#certification_level' do
132
144
  it 'should return nil for an unsigned pdf' do
133
145
  @pdf.certification_level.should == :not_certified
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jpdfer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Scott Nielsen
@@ -11,8 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-01-31 00:00:00 -07:00
15
- default_executable:
14
+ date: 2012-09-21 00:00:00 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: nokogiri
@@ -74,7 +73,6 @@ files:
74
73
  - spec/data/simple_form_signed_by_someone_else.pdf
75
74
  - spec/lib/jpdfer/pdf_spec.rb
76
75
  - spec/spec_helper.rb
77
- has_rdoc: true
78
76
  homepage: http://github.com/scizo/jpdfer
79
77
  licenses: []
80
78
 
@@ -99,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
97
  requirements: []
100
98
 
101
99
  rubyforge_project:
102
- rubygems_version: 1.5.1
100
+ rubygems_version: 1.8.15
103
101
  signing_key:
104
102
  specification_version: 3
105
103
  summary: Read and write PDF forms in JRuby