dragonfly_pdf 0.0.3 → 0.0.4

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: 2f7513fd9507eb6bf49ad4a51d4204264df9c758
4
- data.tar.gz: 235b85f9685ea39fa14dd0e7d25edc876b66142d
3
+ metadata.gz: d92193cc4f8f909e80c010bd9fca663157faa0c6
4
+ data.tar.gz: 87ba359b7501804f78afa53483423f6628e0001f
5
5
  SHA512:
6
- metadata.gz: 6ceffc982e0b65454b263ce97e81aaac26104ac791026184020d2b4b8b9f012cf7dbad491bdc919ea85df685d64450a3193222b95896eea66e7f48214e485936
7
- data.tar.gz: a18b986d6de46ba7ae00072da65b884dbf541dfdac594d2cfa453676236fecae4423304dccb208b4db28a987ce2ea4738bbbc72c92f37735a1b58d1224d2dd91
6
+ metadata.gz: 701d80af8064a7da9caa9a9954053a89e5ab587c5ae2c3cb4d1ee73889d215b5cc3cd3dc47a01e9d9da0e54ef9edbd2b70959aea4a964bf2f114d43eaed205b9
7
+ data.tar.gz: 1adcb08b726408edd4dd6a627d39513efcb170eb31c2ca9cb59c6eb6d5be993b5b64ffe84eb1554a18979e331d03c0d6a691691e0b482092a09c278602e4ba72
data/README.md CHANGED
@@ -37,7 +37,7 @@ end
37
37
  PDFs that contain spreads (as when saving with the spreads option in InDesign) require setting the `spreads` [metadata](http://markevans.github.io/dragonfly/models/#meta-data) attribute to `true`:
38
38
 
39
39
  ```ruby
40
- pdf.metadata['spreads'] = true
40
+ pdf.meta['spreads'] = true
41
41
  ```
42
42
 
43
43
  ## Analysers
@@ -59,7 +59,7 @@ It returns a hash of properties:
59
59
  page_numbers: [[1], [2, 3], [4]],
60
60
  widths: [[210.0], [210.0, 210.0], [210.0]],
61
61
  heights: [[297.0], [297.0, 297.0], [297.0]],
62
- aspect_ratios: [[0.71], [0.71, 0.71], [0.71]],
62
+ aspect_ratios: [[0.71], [0.71, 0.71], [0.71]],
63
63
  info: { … }
64
64
  }
65
65
  ```
@@ -2,6 +2,7 @@ require 'dragonfly_pdf/analysers/pdf_properties'
2
2
 
3
3
  require 'dragonfly_pdf/processors/page'
4
4
  require 'dragonfly_pdf/processors/page_thumb'
5
+ require 'dragonfly_pdf/processors/subset_fonts'
5
6
 
6
7
  module DragonflyPdf
7
8
  class Plugin
@@ -41,9 +42,10 @@ module DragonflyPdf
41
42
 
42
43
  app.add_processor :page_thumb, DragonflyPdf::Processors::PageThumb.new
43
44
  app.add_processor :page, DragonflyPdf::Processors::Page.new
45
+ app.add_processor :subset_fonts, DragonflyPdf::Processors::SubsetFonts.new
44
46
  end
45
47
 
46
48
  end
47
49
  end
48
50
 
49
- Dragonfly::App.register_plugin(:pdf) { DragonflyPdf::Plugin.new }
51
+ Dragonfly::App.register_plugin(:pdf) { DragonflyPdf::Plugin.new }
@@ -0,0 +1,20 @@
1
+ module DragonflyPdf
2
+ module Processors
3
+ class SubsetFonts
4
+
5
+ def call content, opts={}
6
+ content.shell_update(ext: :pdf) do |old_path, new_path|
7
+ "#{gs_command} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSubsetFonts=true -o #{new_path} -f #{old_path}"
8
+ end
9
+ end
10
+
11
+
12
+ private # =============================================================
13
+
14
+ def gs_command
15
+ 'gs'
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,25 @@
1
+ module DragonflyPdf
2
+ module Processors
3
+ describe SubsetFonts do
4
+
5
+ let(:app) { test_app.configure_with(:pdf) }
6
+ let(:processor) { DragonflyPdf::Processors::SubsetFonts.new }
7
+
8
+ let(:sample_pdf) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
9
+
10
+ # =====================================================================
11
+
12
+ it 'returns PDF by default' do
13
+ processor.call(sample_pdf, 1)
14
+ get_mime_type(sample_pdf.path).must_include "application/pdf"
15
+ end
16
+
17
+ private # =============================================================
18
+
19
+ def get_mime_type file_path
20
+ `file --mime-type #{file_path}`.gsub(/\n/, "")
21
+ end
22
+
23
+ end
24
+ end
25
+ 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.0.3
4
+ version: 0.0.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: 2015-01-22 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly
@@ -128,6 +128,7 @@ files:
128
128
  - lib/dragonfly_pdf/plugin.rb
129
129
  - lib/dragonfly_pdf/processors/page.rb
130
130
  - lib/dragonfly_pdf/processors/page_thumb.rb
131
+ - lib/dragonfly_pdf/processors/subset_fonts.rb
131
132
  - lib/dragonfly_pdf/version.rb
132
133
  - samples/sample_pages.pdf
133
134
  - samples/sample_spreads.pdf
@@ -138,6 +139,7 @@ files:
138
139
  - test/dragonfly_pdf/plugin_test.rb
139
140
  - test/dragonfly_pdf/processors/page_test.rb
140
141
  - test/dragonfly_pdf/processors/page_thumb_test.rb
142
+ - test/dragonfly_pdf/processors/subset_fonts.rb
141
143
  - test/test_helper.rb
142
144
  homepage: https://github.com/tomasc/dragonfly_pdf
143
145
  licenses:
@@ -159,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
161
  version: '0'
160
162
  requirements: []
161
163
  rubyforge_project:
162
- rubygems_version: 2.2.2
164
+ rubygems_version: 2.4.8
163
165
  signing_key:
164
166
  specification_version: 4
165
167
  summary: Dragonfly PDF analysers and processors.
@@ -168,4 +170,5 @@ test_files:
168
170
  - test/dragonfly_pdf/plugin_test.rb
169
171
  - test/dragonfly_pdf/processors/page_test.rb
170
172
  - test/dragonfly_pdf/processors/page_thumb_test.rb
173
+ - test/dragonfly_pdf/processors/subset_fonts.rb
171
174
  - test/test_helper.rb