pdftk 0.0.1

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.
@@ -0,0 +1,28 @@
1
+ Pdftk
2
+ =====
3
+
4
+ Pdftk is gem for merging pdf files with pdftk library for Rails.
5
+
6
+ ### Installation
7
+
8
+ Configure it in an initializer:
9
+ Pdftk.config = {
10
+ :exe_path => '/usr/local/bin/pdftk'
11
+ }
12
+
13
+ Next:
14
+
15
+ script/plugin install git://github.com/webkrak/pdftk.git
16
+ script/generate pdftk
17
+
18
+ or add this to your Gemfile:
19
+
20
+ gem 'pdftk'
21
+
22
+ ### Basic Usage
23
+
24
+ Is a example of usage:
25
+
26
+ pdftk = Pdftk.new(array_with_files_path_to_merging, output_file)
27
+ result = pdftk.merge
28
+
@@ -0,0 +1,7 @@
1
+ class PdftkGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.file "pdftk.rb", "config/initializers/pdftk.rb"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ Pdftk.config = {
2
+ :exe_path => '/usr/local/bin/pdftk'
3
+ }
@@ -0,0 +1,25 @@
1
+ class Pdftk
2
+ EXE_NAME = "pdftk"
3
+ @@config = {}
4
+ cattr_accessor :config
5
+
6
+ def initialize(source_array, destination_path)
7
+ @source_files = source_array
8
+ @merged_file_path = destination_path
9
+ raise "Location of #{EXE_PATH} unknow" if @exe_path.empty?
10
+ raise "Bad location of #{EXE_PATH}'s path" unless File.exists?(@exe_path)
11
+ raise "#{EXE_PATH} is not executable" unless File.executable?(@exe_path)
12
+ end
13
+
14
+ def merge
15
+ command = "#{@exe_path} #{@source_files.join(' ')} cat output #{@merged_file_path}"
16
+ err = Open3.popen3(command) do |stdin, stdout, stderr|
17
+ stderr.read
18
+ end
19
+ pdf = @merged_file_path.read
20
+ raise "PDF could not be generated!" if pdf and pdf.rstrip.length == 0
21
+ pdf
22
+ rescue Exception => e
23
+ raise "Failed to execute:\n#{command}\nError: #{e}"
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdftk
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Konrad Glowacki
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-01-30 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: rake
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id002
48
+ description: Pdftk library is used for merging diffrent pdf files.
49
+ email: konrad.glowacki@gmail.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - README.md
58
+ - lib/pdftk.rb
59
+ - generators/pdftk/pdftk_generator.rb
60
+ - generators/pdftk/templates/pdftk.rb
61
+ homepage: https://github.com/webkrak
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.24
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Pdftk library for Rails
94
+ test_files: []
95
+