pdf-burst 0.1.0

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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Joao Carlos and Kisko Labs Oy.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require "pdf-burst"
3
+ PDF::Burst.new(ARGV[0]).run!
@@ -0,0 +1 @@
1
+ require "pdf/burst"
@@ -0,0 +1,38 @@
1
+ module PDF
2
+ class Burst
3
+ def initialize(pdf_path, options={})
4
+ @pdf_path = pdf_path
5
+ @output_path = options[:output_path] || "."
6
+ @page_name = options[:output_filename] || "page_%d"
7
+ end
8
+
9
+ def run!
10
+ page_count.times do |i|
11
+ page_number = i + 1
12
+ system burst_command(page_number)
13
+ end
14
+ end
15
+
16
+ def page_count
17
+ `#{page_count_command}`.to_i
18
+ end
19
+
20
+ private
21
+
22
+ def page_count_command
23
+ "pdfinfo '#{@pdf_path}' | grep 'Pages:' | grep -oP '\\d+'"
24
+ end
25
+
26
+ def burst_command(page_number)
27
+ "gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=#{page_number} -dAutoFilterColorImages=false -dAutoFilterGrayImage=false -dColorImageFilter=/FlateEncode -dLastPage=#{page_number} -sOutputFile='#{output_file_path(page_number)}' '#{@pdf_path}'"
28
+ end
29
+
30
+ def page_filename(page_number)
31
+ @page_name % page_number + ".pdf"
32
+ end
33
+
34
+ def output_file_path(page_number)
35
+ File.expand_path("#{@output_path}/#{page_filename(page_number)}")
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module PDF
2
+ class Burst
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdf-burst
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Joao Carlos
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-01 00:00:00 +03:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "Creates a PDF for each page from a PDF with multiple pages. Uses Ghostscript for the actual bursting. You'll need the following commands available on your system: gs (Ghostscript), pdfinfo (Poppler) and grep."
23
+ email:
24
+ - mail@joao-carlos.com
25
+ executables:
26
+ - pdf-burst
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - lib/pdf/burst/version.rb
33
+ - lib/pdf/burst.rb
34
+ - lib/pdf-burst.rb
35
+ - bin/pdf-burst
36
+ - LICENSE
37
+ has_rdoc: true
38
+ homepage: http://github.com/kiskolabs/pdf-burst
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 21
61
+ segments:
62
+ - 1
63
+ - 3
64
+ - 7
65
+ version: 1.3.7
66
+ requirements: []
67
+
68
+ rubyforge_project: pdf-burst
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Bursts a PDF into single page files
73
+ test_files: []
74
+