dragonfly_pdf 0.2.0 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b630259edd321fc3a4972fc7c5cae40871e050b0
4
- data.tar.gz: 57b09a13cd2c1b4099a56d284519873e792b0fc7
3
+ metadata.gz: c3aeafce83bfa13d67f48b2e26910cd849122f22
4
+ data.tar.gz: cebb15e7d1aba507ea4ad6d5c6db5252a31dd2db
5
5
  SHA512:
6
- metadata.gz: 2185816838240ea29832527c758e9648a37038bdbd8f8d893eef372dd33941820730ebbe3faa1d7d082b47494ff9b1e563bddf2d5e11cadd4e414a0198233520
7
- data.tar.gz: 52a19c0bddb5ce97f81a57ceb43f5e369b34343034af72b3af770b314303286318f21177d6bad56240cfe2cd5649ea40a9dec61c96220e9ceade68fd182c8ad1
6
+ metadata.gz: e078c2a014b5645415e5475053b57fba8032cfc6cade9abc1c277d50d34e957bcee27e2d22d8cb1f29340ed34d262ef6a17eb4a97a1d73d5f1c2ce8b568440cd
7
+ data.tar.gz: 684d981812ff6d63b777a32b1b756ac874de6fed70b0c64dc506b2cdf2fa51904c060584285cc9d33fd8fe40e0721d812d38cd77cc3a7c395796fb38f0a911c5
@@ -1,3 +1,7 @@
1
+ ## 0.2.3
2
+
3
+ * added: `:page_rotations` data to `pdf_properties`
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  * refactor: read PDF attributes directly
data/README.md CHANGED
@@ -44,9 +44,8 @@ pdf.pdf_properties # => {
44
44
  page_count: 4,
45
45
  page_dimensions: [[210.0, 297.0], [210.0, 297.0], [210.0, 297.0], [210.0, 297.0]],
46
46
  page_numbers: [1, 2, 3, 4],
47
- widths: [210.0, 210.0, 210.0, 210.0],
48
- heights: [297.0, 297.0, 297.0, 297.0],
49
- aspect_ratios: [0.71, 0.71, 0.71, 0.71]
47
+ aspect_ratios: [0.71, 0.71, 0.71, 0.71],
48
+ page_rotations: [0.0, 90.0, 0.0, 0.0]
50
49
  }
51
50
  ```
52
51
 
@@ -5,8 +5,10 @@ module DragonflyPdf
5
5
  box_type = options.fetch :box_type, 'TrimBox'
6
6
 
7
7
  box_data = []
8
+ rotate_data = []
8
9
  IO.foreach(content.path, "\n\n", encoding: "ISO-8859-1") do |item|
9
10
  box_data += item.scan(/(MediaBox|CropBox|BleedBox|TrimBox)\s?\[([\d\.]+?)\s([\d\.]+?)\s([\d\.]+?)\s([\d\.]+?)\]/)
11
+ rotate_data += item.scan(/\/Rotate\s(\d+?)\s/)
10
12
  end
11
13
 
12
14
  # drop last value, since that comes from data about all pages
@@ -21,12 +23,14 @@ module DragonflyPdf
21
23
  page_count = page_dimensions.count
22
24
  aspect_ratios = page_dimensions.inject([]) { |res, page| res << (page.first / page.last) }
23
25
  page_numbers = (1..page_count).to_a
26
+ page_rotations = rotate_data.flatten.map(&:to_f)
24
27
 
25
28
  {
26
29
  aspect_ratios: aspect_ratios,
27
30
  page_count: page_count,
28
31
  page_dimensions: page_dimensions,
29
- page_numbers: page_numbers
32
+ page_numbers: page_numbers,
33
+ page_rotations: page_rotations
30
34
  }
31
35
  end
32
36
 
@@ -23,12 +23,8 @@ module DragonflyPdf
23
23
  content.analyse(:pdf_properties)[:page_dimensions]
24
24
  end
25
25
 
26
- app.add_analyser :widths do |content|
27
- content.analyse(:pdf_properties)[:widths]
28
- end
29
-
30
- app.add_analyser :heights do |content|
31
- content.analyse(:pdf_properties)[:heights]
26
+ app.add_analyser :page_rotations do |content|
27
+ content.analyse(:pdf_properties)[:page_rotations]
32
28
  end
33
29
 
34
30
  app.add_analyser :aspect_ratios do |content|
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -7,6 +7,7 @@ module DragonflyPdf
7
7
  let(:analyser) { DragonflyPdf::Analysers::PdfProperties.new }
8
8
  let(:sample_pages) { app.fetch_file(SAMPLES_DIR.join('sample_pages.pdf')) }
9
9
  let(:sample_pages_with_bleed) { app.fetch_file(SAMPLES_DIR.join('sample_pages_with_bleed.pdf')) }
10
+ let(:sample_pages_rotated) { app.fetch_file(SAMPLES_DIR.join('sample_pages_rotated.pdf')) }
10
11
 
11
12
  # =====================================================================
12
13
 
@@ -39,6 +40,12 @@ module DragonflyPdf
39
40
  analyser.call(sample_pages_with_bleed)[:aspect_ratios].map{ |i| i.round(2) }.must_equal [0.71].cycle.take(1)
40
41
  end
41
42
  end
43
+
44
+ describe '#page_rotations' do
45
+ it 'returns correct page count' do
46
+ analyser.call(sample_pages_rotated)[:page_rotations].must_equal [0.0, 90.0, 180.0, 270.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
47
+ end
48
+ end
42
49
  end
43
50
  end
44
51
  end
@@ -28,17 +28,13 @@ module DragonflyPdf
28
28
  pdf.must_respond_to :page_dimensions
29
29
  end
30
30
 
31
- it 'adds #widths' do
32
- pdf.must_respond_to :widths
33
- end
34
-
35
- it 'adds #heights' do
36
- pdf.must_respond_to :heights
37
- end
38
-
39
31
  it 'adds #aspect_ratios' do
40
32
  pdf.must_respond_to :aspect_ratios
41
33
  end
34
+
35
+ it 'adds #page_rotations' do
36
+ pdf.must_respond_to :page_rotations
37
+ end
42
38
  end
43
39
 
44
40
  # ---------------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
@@ -136,6 +136,7 @@ files:
136
136
  - lib/dragonfly_pdf/processors/subset_fonts.rb
137
137
  - lib/dragonfly_pdf/version.rb
138
138
  - samples/sample_pages.pdf
139
+ - samples/sample_pages_rotated.pdf
139
140
  - samples/sample_pages_with_bleed.pdf
140
141
  - samples/sample_stamp.pdf
141
142
  - test/dragonfly_pdf/analysers/pdf_properties_test.rb