dragonfly_pdf 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3aeafce83bfa13d67f48b2e26910cd849122f22
4
- data.tar.gz: cebb15e7d1aba507ea4ad6d5c6db5252a31dd2db
3
+ metadata.gz: d3e59a245f47b7c1e155fe0ec8acd70a8116e7e6
4
+ data.tar.gz: c91655b09e67dec8b2b8e6c929383239248f0022
5
5
  SHA512:
6
- metadata.gz: e078c2a014b5645415e5475053b57fba8032cfc6cade9abc1c277d50d34e957bcee27e2d22d8cb1f29340ed34d262ef6a17eb4a97a1d73d5f1c2ce8b568440cd
7
- data.tar.gz: 684d981812ff6d63b777a32b1b756ac874de6fed70b0c64dc506b2cdf2fa51904c060584285cc9d33fd8fe40e0721d812d38cd77cc3a7c395796fb38f0a911c5
6
+ metadata.gz: cd01b1b73d60661fc19f9f6953838631208f383b0fbd340d6bc37b7dbe33c217d99b8587574b034ebc44d9691386cfb059be5b2270c6102fa2499acf9a5274a7
7
+ data.tar.gz: 0cee5d23bde1ee22c975d4288722030a00bc8d097b1e3e3957df078cbbefa8d4d2767b1c66b0a9bf5431dd0c98a6ac8a654f6deb671aaad8328e0e3a616102fd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.4
2
+
3
+ * added: `:remove_password`
4
+
1
5
  ## 0.2.3
2
6
 
3
7
  * added: `:page_rotations` data to `pdf_properties`
data/README.md CHANGED
@@ -92,6 +92,14 @@ The available options and their default values are:
92
92
  }
93
93
  ```
94
94
 
95
+ ### Remove password
96
+
97
+ Remove password from password protected PDF.
98
+
99
+ ```ruby
100
+ pdf.remove_password
101
+ ```
102
+
95
103
  ### Rotate
96
104
 
97
105
  Rotate all pages.
@@ -2,6 +2,7 @@ require 'dragonfly_pdf/analysers/pdf_properties'
2
2
  require 'dragonfly_pdf/processors/append'
3
3
  require 'dragonfly_pdf/processors/page'
4
4
  require 'dragonfly_pdf/processors/page_thumb'
5
+ require 'dragonfly_pdf/processors/remove_password'
5
6
  require 'dragonfly_pdf/processors/rotate'
6
7
  require 'dragonfly_pdf/processors/stamp'
7
8
  require 'dragonfly_pdf/processors/subset_fonts'
@@ -36,6 +37,7 @@ module DragonflyPdf
36
37
  app.add_processor :append, DragonflyPdf::Processors::Append.new
37
38
  app.add_processor :page, DragonflyPdf::Processors::Page.new
38
39
  app.add_processor :page_thumb, DragonflyPdf::Processors::PageThumb.new
40
+ app.add_processor :remove_password, DragonflyPdf::Processors::RemovePassword.new
39
41
  app.add_processor :rotate, DragonflyPdf::Processors::Rotate.new
40
42
  app.add_processor :stamp, DragonflyPdf::Processors::Stamp.new
41
43
  app.add_processor :subset_fonts, DragonflyPdf::Processors::SubsetFonts.new
@@ -0,0 +1,17 @@
1
+ module DragonflyPdf
2
+ module Processors
3
+ class RemovePassword
4
+ def call(content, _options = {})
5
+ content.shell_update(ext: :pdf) do |old_path, new_path|
6
+ "#{gs_command} -q -sOutputFile=#{new_path} -c .setpdfwrite -f #{old_path}"
7
+ end
8
+ end
9
+
10
+ private # =============================================================
11
+
12
+ def gs_command
13
+ "gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -40,12 +40,27 @@ module DragonflyPdf
40
40
  # ---------------------------------------------------------------------
41
41
 
42
42
  describe 'processors' do
43
+ it 'adds #append' do
44
+ pdf.must_respond_to :append
45
+ end
43
46
  it 'adds #page' do
44
47
  pdf.must_respond_to :page
45
48
  end
46
49
  it 'adds #page_thumb' do
47
50
  pdf.must_respond_to :page_thumb
48
51
  end
52
+ it 'adds #remove_password' do
53
+ pdf.must_respond_to :remove_password
54
+ end
55
+ it 'adds #rotate' do
56
+ pdf.must_respond_to :rotate
57
+ end
58
+ it 'adds #stamp' do
59
+ pdf.must_respond_to :stamp
60
+ end
61
+ it 'adds #subset_fonts' do
62
+ pdf.must_respond_to :subset_fonts
63
+ end
49
64
  end
50
65
  end
51
66
  end
@@ -0,0 +1,26 @@
1
+ require 'pdf-reader'
2
+ require 'test_helper'
3
+
4
+ module DragonflyPdf
5
+ module Processors
6
+ describe RemovePassword do
7
+ let(:app) { test_app.configure_with(:pdf) }
8
+ let(:processor) { DragonflyPdf::Processors::RemovePassword.new }
9
+ let(:sample_pages) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages_with_password.pdf')) }
10
+ let(:result) { PDF::Reader.new(sample_pages.path) }
11
+
12
+ # =====================================================================
13
+
14
+ it 'returns PDF by default' do
15
+ processor.call(sample_pages, 1)
16
+ get_mime_type(sample_pages.path).must_include 'application/pdf'
17
+ end
18
+
19
+ # ---------------------------------------------------------------------
20
+
21
+ def get_mime_type(file_path)
22
+ `file --mime-type #{file_path}`.gsub(/\n/, '')
23
+ end
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-24 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly
@@ -131,6 +131,7 @@ files:
131
131
  - lib/dragonfly_pdf/processors/append.rb
132
132
  - lib/dragonfly_pdf/processors/page.rb
133
133
  - lib/dragonfly_pdf/processors/page_thumb.rb
134
+ - lib/dragonfly_pdf/processors/remove_password.rb
134
135
  - lib/dragonfly_pdf/processors/rotate.rb
135
136
  - lib/dragonfly_pdf/processors/stamp.rb
136
137
  - lib/dragonfly_pdf/processors/subset_fonts.rb
@@ -138,12 +139,14 @@ files:
138
139
  - samples/sample_pages.pdf
139
140
  - samples/sample_pages_rotated.pdf
140
141
  - samples/sample_pages_with_bleed.pdf
142
+ - samples/sample_pages_with_password.pdf
141
143
  - samples/sample_stamp.pdf
142
144
  - test/dragonfly_pdf/analysers/pdf_properties_test.rb
143
145
  - test/dragonfly_pdf/plugin_test.rb
144
146
  - test/dragonfly_pdf/processors/append_test.rb
145
147
  - test/dragonfly_pdf/processors/page_test.rb
146
148
  - test/dragonfly_pdf/processors/page_thumb_test.rb
149
+ - test/dragonfly_pdf/processors/remove_password_test.rb
147
150
  - test/dragonfly_pdf/processors/rotate_test.rb
148
151
  - test/dragonfly_pdf/processors/stamp_test.rb
149
152
  - test/dragonfly_pdf/processors/subset_fonts.rb
@@ -178,6 +181,7 @@ test_files:
178
181
  - test/dragonfly_pdf/processors/append_test.rb
179
182
  - test/dragonfly_pdf/processors/page_test.rb
180
183
  - test/dragonfly_pdf/processors/page_thumb_test.rb
184
+ - test/dragonfly_pdf/processors/remove_password_test.rb
181
185
  - test/dragonfly_pdf/processors/rotate_test.rb
182
186
  - test/dragonfly_pdf/processors/stamp_test.rb
183
187
  - test/dragonfly_pdf/processors/subset_fonts.rb