pdfunite 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89773309019915428c104ddf686d5a3d2cf35606
4
+ data.tar.gz: 8e0a20e7120789a152724fb2463081a70006f571
5
+ SHA512:
6
+ metadata.gz: dc388270803c5927874755b242736257468d87cae8cf7c2762a143510d7b9bb2d0b2e30be7684a6b271e203f404d19f2621be088c6269be6d62e4d316c7d741b
7
+ data.tar.gz: cd4f0501cbafa5179d1255dc3e540ec8b22356fc14cfa3dde56135a84aa50103b4860e035e528458f41df46dc08f18d1c993bf29745d2a5893b354f030e36480
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,44 @@
1
+ # Pdfunite
2
+
3
+ Merge PDF files with Ruby.
4
+
5
+ Pdfunite is a Ruby wrapper for the pdfunite command line tool. No Java required.
6
+
7
+ ## Installation
8
+
9
+ Pdfunite requires the ```pdfunite``` command line tool, which uses the `poppler` library.
10
+
11
+ ### Linux
12
+
13
+ Install the `poppler-utils` package using your package manager.
14
+
15
+ ### OS X
16
+
17
+ Install `poppler` using Homebrew.
18
+
19
+ ### In your app
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ # Gemfile
25
+ gem 'pdfunite'
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ # Join existing PDF files
32
+ pdf_data = Pdfunite.join('file1.pdf', 'file2.pdf', 'file3.pdf')
33
+
34
+ # Join PDF binary data provided by a collection of objects
35
+ pdf_data = Pdfunite.join(objects) { |obj| obj.to_pdf }
36
+ ```
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/[my-github-username]/pdfunite/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rdoc/task'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Run all tests'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.test_files = FileList['test/unit/*_test.rb']
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Pdfunite'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README.md')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
@@ -0,0 +1,47 @@
1
+ require 'pdfunite/version'
2
+ require 'pathname'
3
+ require 'cocaine'
4
+ require 'logger'
5
+
6
+ module Pdfunite
7
+
8
+ class << self
9
+
10
+ @@logger = nil
11
+
12
+ # You can set a custom logger here
13
+ def logger=(logger)
14
+ @@logger = logger
15
+ end
16
+
17
+ def logger
18
+ @@logger
19
+ end
20
+
21
+ #
22
+ # Join PDF files or PDF data
23
+ #
24
+ # Pdfunite.join(filenames)
25
+ # Pdfunite.join(objects) { |obj| obj.to_pdf }
26
+ #
27
+ def join(*args)
28
+ output = nil
29
+ Dir.mktmpdir do |dir|
30
+ tmpdir = Pathname.new(dir).realpath
31
+ files = args.flatten(1).inject({}) do |hsh, arg|
32
+ idx = hsh.size
33
+ data = block_given? ? yield(arg) : File.binread(arg)
34
+ tmpfile = tmpdir.join("#{idx}.pdf")
35
+ tmpfile.open('wb') { |f| f << data }
36
+ hsh.update(:"f_#{idx}" => tmpfile.realpath.to_s)
37
+ end
38
+ cmdline = Cocaine::CommandLine.new('pdfunite', "#{files.keys.map(&:inspect).join(' ')} :outfile", logger: Pdfunite.logger || Logger.new(STDOUT))
39
+ outfile = tmpdir.join('output.pdf')
40
+ cmdline.run(files.merge(outfile: outfile.to_s))
41
+ output = outfile.binread
42
+ end
43
+ output
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,3 @@
1
+ module Pdfunite
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdfunite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthias Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocaine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ description: Ruby wrapper for the pdfunite command line tool. No Java required
98
+ email:
99
+ - mtgrosser@gmx.net
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - Gemfile
105
+ - README.md
106
+ - Rakefile
107
+ - lib/pdfunite.rb
108
+ - lib/pdfunite/version.rb
109
+ homepage: https://github.com/mtgrosser/pdfunite
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.2.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Merge PDF files with Ruby
133
+ test_files: []