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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -3
- data/lib/dragonfly_pdf/analysers/pdf_properties.rb +5 -1
- data/lib/dragonfly_pdf/plugin.rb +2 -6
- data/lib/dragonfly_pdf/version.rb +1 -1
- data/samples/sample_pages_rotated.pdf +0 -0
- data/test/dragonfly_pdf/analysers/pdf_properties_test.rb +7 -0
- data/test/dragonfly_pdf/plugin_test.rb +4 -8
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3aeafce83bfa13d67f48b2e26910cd849122f22
|
4
|
+
data.tar.gz: cebb15e7d1aba507ea4ad6d5c6db5252a31dd2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e078c2a014b5645415e5475053b57fba8032cfc6cade9abc1c277d50d34e957bcee27e2d22d8cb1f29340ed34d262ef6a17eb4a97a1d73d5f1c2ce8b568440cd
|
7
|
+
data.tar.gz: 684d981812ff6d63b777a32b1b756ac874de6fed70b0c64dc506b2cdf2fa51904c060584285cc9d33fd8fe40e0721d812d38cd77cc3a7c395796fb38f0a911c5
|
data/CHANGELOG.md
CHANGED
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
|
-
|
48
|
-
|
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
|
|
data/lib/dragonfly_pdf/plugin.rb
CHANGED
@@ -23,12 +23,8 @@ module DragonflyPdf
|
|
23
23
|
content.analyse(:pdf_properties)[:page_dimensions]
|
24
24
|
end
|
25
25
|
|
26
|
-
app.add_analyser :
|
27
|
-
content.analyse(:pdf_properties)[:
|
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|
|
Binary file
|
@@ -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.
|
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
|