pdfs2pdf 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f61699303fc3242f39bcf101d33b2fa86e799b14
4
+ data.tar.gz: 5d59dc62ee411712790a4c6a193e922593b165f9
5
+ SHA512:
6
+ metadata.gz: d043ab8c3fd081b43ed26bd6ff5a3e36bf8d0834bee39317008ca4b40bac14b93a530ffe6b044b82819460c9820138825d3076317b0cc2928475c64bc497363f
7
+ data.tar.gz: d61b0241e377d1ebd04e1bc23b5d91181ae080cb8040d42a51ba1772a8c36d31bea28970e78d095d15a1b24a444032882d9fe05162b20c38567803e2613eae29
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 1.9.3
1
+ 2.1.1
data/CHANGELOGS.md ADDED
@@ -0,0 +1,36 @@
1
+ ### Changelogs
2
+
3
+ #### 0.0.6
4
+
5
+ - Allow options for wkhtmltopdf to be more customizable
6
+ * page_size: 'A4', 'Letter' can be set via configuration
7
+ * path to the 'wkhtmltopdf' can be set via configuration
8
+ * the 'pdfmarks metadata' can be set via configuration
9
+ * more options will be enabled in upcoming release
10
+ - Remove the changelogs section from README.md to CHANGLOGS.md
11
+
12
+ #### 0.0.5
13
+
14
+ - Update to latest dependencies
15
+ - Add links to CodeClimate and Gemnasium
16
+
17
+ #### 0.0.4
18
+
19
+ - Remove unused codes
20
+ - Update [agile_utils][] to 0.0.8
21
+ - Update [code_lister][] to 0.0.7
22
+
23
+ #### 0.0.3
24
+
25
+ - Update to [agile_utils][] which fix some minor bug
26
+
27
+ #### 0.0.2
28
+
29
+ - Fix incorrect version badge
30
+
31
+ #### 0.0.1
32
+
33
+ - Initial release
34
+
35
+ [Ghostscript]: http://www.ghostscript.com/
36
+ [Wkhtmltopdf]: http://wkhtmltopdf.org/
data/README.md CHANGED
@@ -130,31 +130,6 @@ letters, numbers and/or underscore characters. Any other characters like
130
130
  * Solution: try rename your folder to 'something_with_underscore' but not
131
131
  'something-with-dash' before running the command.
132
132
 
133
- ### Changelogs
134
-
135
- #### 0.0.5
136
-
137
- - Update to latest dependencies
138
- - Add links to CodeClimate and Gemnasium
139
-
140
- #### 0.0.4
141
-
142
- - Remove unused codes
143
- - Update [agile_utils][] to 0.0.8
144
- - Update [code_lister][] to 0.0.7
145
-
146
- #### 0.0.3
147
-
148
- - Update to [agile_utils][] which fix some minor bug
149
-
150
- #### 0.0.2
151
-
152
- - Fix incorrect version badge
153
-
154
- #### 0.0.1
155
-
156
- - Initial release
157
-
158
133
  ### Contributing
159
134
 
160
135
  1. Fork it ( http://github.com/agilecreativity/pdfs2pdf/fork )
data/bin/pdfs2pdf CHANGED
@@ -1,4 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/pdfs2pdf'
3
+
4
+ # The default configuration
5
+ require_relative '../config/initializers/pdfs2pdf'
6
+ Pdfs2Pdf.update_config()
7
+
3
8
  include Pdfs2Pdf
4
9
  Pdfs2Pdf::CLI.start(ARGV)
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+ module Pdfs2Pdf
3
+ class << self
4
+ # Customize the configuration for specific system (Ubuntu/OSX/etc)
5
+ # See: ./lib/pdfs2pdf/configuration.rb for available options
6
+ def update_config
7
+ Pdfs2Pdf.configure do |config|
8
+ # config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
9
+ # config.default_options = {
10
+ # paper_size: 'Letter',
11
+ # ..
12
+ # }
13
+ # config.pdfmarks_meta = ..
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/pdfs2pdf/cli.rb CHANGED
@@ -1,12 +1,13 @@
1
+ # coding: utf-8
1
2
  require 'thor'
2
3
  require 'tmpdir'
3
4
  require 'fileutils'
4
5
  require_relative '../pdfs2pdf'
5
6
  require_relative './utils'
6
-
7
7
  module Pdfs2Pdf
8
8
  include AgileUtils::Options
9
9
  include CodeLister
10
+
10
11
  class CLI < Thor
11
12
  desc 'merge', 'Combine multiple pdfs into one file with bookmarks'
12
13
  method_option *AgileUtils::Options::BASE_DIR
@@ -58,7 +59,7 @@ Combine multiple pdfs into one file with bookmarks
58
59
 
59
60
  def merge_pdfs(pdf_files)
60
61
  elapsed = AgileUtils::FileUtil.time do
61
- Pdfs2Pdf::Utils.merge_pdfs(pdf_files, 'pdfmarks', 'final_output.pdf')
62
+ Utils.merge_pdfs(pdf_files, 'pdfmarks', 'final_output.pdf')
62
63
  end
63
64
  puts "Combine pdf files took #{elapsed} ms"
64
65
  puts "Your combine pdf is available at #{File.absolute_path('final_output.pdf')}"
@@ -0,0 +1,52 @@
1
+ # coding: utf-8
2
+ module Pdfs2Pdf
3
+ class Configuration
4
+ attr_accessor :default_options,
5
+ :pdfmarks_meta,
6
+ :wkhtmltopdf
7
+
8
+ def initialize
9
+ # see: http://wkhtmltopdf.org/usage/wkhtmltopdf.txt
10
+ @default_options = {
11
+ paper_size: 'A4', # 'Letter'
12
+ # Note: placeholder values, will be added in the up coming release!
13
+ margin_top: '0.75in',
14
+ margin_right: '0.75in',
15
+ margin_bottom: '0.75in',
16
+ margin_left: '0.75in',
17
+ encoding: 'UTF-8'
18
+ }
19
+
20
+ # see: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf
21
+ @pdfmarks_meta = <<-END.gsub(/^\s+\|/, '')
22
+ |[ /Title (My Combined Pdf)
23
+ | /Author (Burin Choomnuan)
24
+ | /Keywords (fun, witty, interesting)
25
+ | /DOCINFO pdfmark
26
+ END
27
+
28
+ @wkhtmltopdf = (defined?(Bundler::GemfileError) ? `bundle exec which wkhtmltopdf` : `which wkhtmltopdf`).chomp
29
+ end
30
+ end
31
+
32
+ class << self
33
+ attr_accessor :configuration
34
+
35
+ # Configure Pdfs2Pdf someplace sensible, like
36
+ # config/initializers/pdfs2pdf.rb
37
+ #
38
+ # @example
39
+ #
40
+ # Pdfs2pdf.configure do |config|
41
+ # # set the path to wkhtmltopdf
42
+ # config.wkhtmltopdf = '/usr/bin/wkhtmltopdf'
43
+ # end
44
+ def configuration
45
+ @configuration ||= Configuration.new
46
+ end
47
+
48
+ def configure
49
+ yield(configuration)
50
+ end
51
+ end
52
+ end
@@ -1,9 +1,11 @@
1
+ # coding: utf-8
1
2
  require 'open3'
2
3
  require 'fileutils'
3
4
  require 'pdf-reader'
4
5
  require_relative '../pdfs2pdf'
6
+ require_relative './configuration'
5
7
  module Pdfs2Pdf
6
- module Utils
8
+ class Utils
7
9
  class << self
8
10
  # Create the 'pdfmarks' file for use with 'gs' utility
9
11
  #
@@ -12,7 +14,7 @@ module Pdfs2Pdf
12
14
  # @param [String] base_dir the base directory (TODO: review this code!)
13
15
  def create_pdfmarks(pdf_files, pdfmarks_file = 'pdfmarks', base_dir = Dir.pwd)
14
16
  File.open(pdfmarks_file, 'w') do |out_file|
15
- out_file.write(title)
17
+ out_file.write(Pdfs2Pdf.configuration.pdfmarks_meta)
16
18
  current_page = 1
17
19
  pdf_files.each do |pdf_file|
18
20
  filename = if base_dir
@@ -22,36 +24,25 @@ module Pdfs2Pdf
22
24
  pdf_file
23
25
  end
24
26
  out_file.write "[ /Page #{current_page} /Title (#{filename}) /OUT pdfmark\n"
25
- current_page += Pdfs2Pdf::Utils.page_count(pdf_file)
27
+ current_page += page_count(pdf_file)
26
28
  end
27
29
  end
28
30
  end
29
31
 
30
- # Simple title for use in 'pdfmarks' file
31
- #
32
- # @todo allow the customization.
33
- def title
34
- <<-END.gsub(/^\s+\|/, '')
35
- |[ /Title (My Sample Book)
36
- | /Author (Agile Creativity)
37
- | /Keywords (fun, witty, interesting)
38
- | /DOCINFO pdfmark
39
- END
40
- end
41
-
42
- # Merge list of files using 'gs' command
32
+ # Merge/combine list of pdf files using Ghostscript's `gs` command
43
33
  #
44
34
  # @param [Array<String>] list input file list
45
35
  # @param [String] pdfmarks the pdfmarks file default to 'pdfmarks'
46
36
  # @param [String] output_file the output pdf file
47
37
  def merge_pdfs(list, pdfmarks = 'pdfmarks', output_file = 'output.pdf')
38
+ paper_size = Pdfs2Pdf.configuration.default_options[:paper_size]
48
39
  _stdin, _stderr, status = Open3.capture3(
49
40
  'gs',
50
41
  '-q',
51
42
  '-dNOPAUSE',
52
43
  '-dBATCH',
53
44
  '-sDEVICE=pdfwrite',
54
- '-sPAPERSIZE=a4',
45
+ "-sPAPERSIZE=#{paper_size}",
55
46
  "-sOutputFile=#{output_file}",
56
47
  *list,
57
48
  pdfmarks)
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  module Pdfs2Pdf
2
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
3
4
  end
data/lib/pdfs2pdf.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require 'agile_utils'
2
3
  require 'code_lister'
3
4
  require_relative 'pdfs2pdf/version'
@@ -6,4 +7,3 @@ require_relative 'pdfs2pdf/utils'
6
7
  include AgileUtils::Options
7
8
  include CodeLister
8
9
  include Pdfs2Pdf
9
- include Pdfs2Pdf::Utils
data/pdfmarks CHANGED
@@ -1,5 +1,5 @@
1
- [ /Title (My Sample Book)
2
- /Author (Agile Creativity)
1
+ [ /Title (My Combined Pdf)
2
+ /Author (Burin Choomnuan)
3
3
  /Keywords (fun, witty, interesting)
4
4
  /DOCINFO pdfmark
5
5
  [ /Page 1 /Title (demo1_xxx.rb.xhtml.pdf/demo1_xxx.rb.xhtml.pdf) /OUT pdfmark
metadata CHANGED
@@ -1,222 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfs2pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Burin Choomnuan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-04-29 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: agile_utils
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.0.9
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.0.9
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: code_lister
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.0.8
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.0.8
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: pdf-reader
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 1.3.3
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 1.3.3
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bundler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
75
  version: '1.5'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
82
  version: '1.5'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: gem-ctags
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
89
  version: '1.0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
96
  version: '1.0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: guard-minitest
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
103
  version: '2.2'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
110
  version: '2.2'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: minitest
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ~>
115
+ - - "~>"
132
116
  - !ruby/object:Gem::Version
133
117
  version: '5.3'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ~>
122
+ - - "~>"
140
123
  - !ruby/object:Gem::Version
141
124
  version: '5.3'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: minitest-spec-context
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ~>
129
+ - - "~>"
148
130
  - !ruby/object:Gem::Version
149
131
  version: 0.0.3
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ~>
136
+ - - "~>"
156
137
  - !ruby/object:Gem::Version
157
138
  version: 0.0.3
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: pry
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ~>
143
+ - - "~>"
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0.9'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ~>
150
+ - - "~>"
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0.9'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: rake
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ~>
157
+ - - "~>"
180
158
  - !ruby/object:Gem::Version
181
159
  version: '10.1'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ~>
164
+ - - "~>"
188
165
  - !ruby/object:Gem::Version
189
166
  version: '10.1'
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: rubocop
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ~>
171
+ - - "~>"
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0.20'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ~>
178
+ - - "~>"
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0.20'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: yard
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - ~>
185
+ - - "~>"
212
186
  - !ruby/object:Gem::Version
213
187
  version: '0.8'
214
188
  type: :development
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - ~>
192
+ - - "~>"
220
193
  - !ruby/object:Gem::Version
221
194
  version: '0.8'
222
195
  description: Combine multiple pdfs into a single file with bookmarks for easy navigation
@@ -227,16 +200,18 @@ executables:
227
200
  extensions: []
228
201
  extra_rdoc_files: []
229
202
  files:
230
- - .gitignore
231
- - .rspec
232
- - .rubocop.yml
233
- - .ruby-version
203
+ - ".gitignore"
204
+ - ".rspec"
205
+ - ".rubocop.yml"
206
+ - ".ruby-version"
207
+ - CHANGELOGS.md
234
208
  - Gemfile
235
209
  - Guardfile
236
210
  - LICENSE.txt
237
211
  - README.md
238
212
  - Rakefile
239
213
  - bin/pdfs2pdf
214
+ - config/initializers/pdfs2pdf.rb
240
215
  - demo1.png
241
216
  - demo2.png
242
217
  - demo3.png
@@ -244,6 +219,7 @@ files:
244
219
  - final_output.png
245
220
  - lib/pdfs2pdf.rb
246
221
  - lib/pdfs2pdf/cli.rb
222
+ - lib/pdfs2pdf/configuration.rb
247
223
  - lib/pdfs2pdf/utils.rb
248
224
  - lib/pdfs2pdf/version.rb
249
225
  - pdfmarks
@@ -258,27 +234,26 @@ files:
258
234
  homepage: https://github.com/agilecreativity/pdfs2pdf
259
235
  licenses:
260
236
  - MIT
237
+ metadata: {}
261
238
  post_install_message:
262
239
  rdoc_options: []
263
240
  require_paths:
264
241
  - lib
265
242
  required_ruby_version: !ruby/object:Gem::Requirement
266
- none: false
267
243
  requirements:
268
- - - ! '>='
244
+ - - ">="
269
245
  - !ruby/object:Gem::Version
270
246
  version: '0'
271
247
  required_rubygems_version: !ruby/object:Gem::Requirement
272
- none: false
273
248
  requirements:
274
- - - ! '>='
249
+ - - ">="
275
250
  - !ruby/object:Gem::Version
276
251
  version: '0'
277
252
  requirements: []
278
253
  rubyforge_project:
279
- rubygems_version: 1.8.23
254
+ rubygems_version: 2.2.2
280
255
  signing_key:
281
- specification_version: 3
256
+ specification_version: 4
282
257
  summary: Combine multiple pdfs into one pdf with proper bookmarks for easy navigation
283
258
  test_files:
284
259
  - test/fixtures/samples/demo1_xxx.rb.xhtml.pdf