htmlToPdf 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/wkhtmltopdf +0 -0
- data/htmlToPdf.gemspec +23 -0
- data/lib/htmlToPdf.rb +39 -0
- data/lib/htmlToPdf/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b6e08a99588e30ca2272d553a0ba42f4e7966c4f
|
4
|
+
data.tar.gz: 1050f9efcd6197eb277a681a2e568abbf2a2c684
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16a952e3949c45da7dc3bb133b24d297abeb227265f661a0d39415d7a1e5a7f1b224c2bbd77f3fc85d5417fe1acb4a4b675277ac21a3625c9f66a76563946352
|
7
|
+
data.tar.gz: bd725fb973840b8a9ffe76714c943aa9bf8037153238d456781f5f75b2f99df1c9a7a33ec5dc12135b7321ee4e523da035baa6264b6647ae949799b5875a39dc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ram Laxman Yadav
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# HtmlToPdf
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'htmlToPdf'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install htmlToPdf
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/htmlToPdf/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/wkhtmltopdf
ADDED
Binary file
|
data/htmlToPdf.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'htmlToPdf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "htmlToPdf"
|
8
|
+
spec.version = HtmlToPdf::VERSION
|
9
|
+
spec.authors = ["Ram Laxman Yadav"]
|
10
|
+
spec.email = ["yadavramlaxman@gmail.com"]
|
11
|
+
spec.summary = %q{html to pdf converter gem}
|
12
|
+
spec.description = %q{this gem will generate pdf of given html using wkhtmmltopdf}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ["wkhtmltopdf"]
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/htmlToPdf.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "htmlToPdf/version"
|
2
|
+
|
3
|
+
module HtmlToPdf
|
4
|
+
|
5
|
+
def html_to_pdf()
|
6
|
+
pdf_options = params[:pdf_options] if params[:pdf_options]
|
7
|
+
if request.format == 'application/pdf'
|
8
|
+
initialize_downloads(pdf_options)
|
9
|
+
FileUtils.mkdir_p(File.join(Rails.root, 'tmp'))
|
10
|
+
_source_file = File.join(Rails.root, 'tmp', "#{Time.now.to_i.to_s}.html")
|
11
|
+
_destination_file = File.join(Rails.root, 'tmp', "#{@name}.pdf")
|
12
|
+
_html = render_to_string(:action => "#{action_name}", :formats => 'html', :layout => @layout )
|
13
|
+
File.open(_source_file, "w+") do |f|
|
14
|
+
f.write(_html)
|
15
|
+
end
|
16
|
+
spec = Gem::Specification.find_by_name("htmlToPdf")
|
17
|
+
gem_root = spec.gem_dir
|
18
|
+
gem_lib = gem_root + "/bin"
|
19
|
+
lib_path = "#{gem_lib}/wkhtmltopdf"
|
20
|
+
|
21
|
+
`#{lib_path} #{_source_file} #{_destination_file}`
|
22
|
+
File.delete(_source_file) if File.exist?(_source_file)
|
23
|
+
send_data File.open(_destination_file, "rb") { |f| f.read }, :disposition => 'attachment',:filename => "#{@name}.pdf"
|
24
|
+
File.delete(_destination_file)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize_downloads(pdf_options)
|
29
|
+
if pdf_options
|
30
|
+
@name = pdf_options[:title].nil? ? 'test' : pdf_options[:title]
|
31
|
+
@layout = pdf_options[:layout].nil? ? 'application' : pdf_options[:layout]
|
32
|
+
else
|
33
|
+
@name = 'test'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
ActionController::Base.send(:include, HtmlToPdf)
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: htmlToPdf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ram Laxman Yadav
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: this gem will generate pdf of given html using wkhtmmltopdf
|
42
|
+
email:
|
43
|
+
- yadavramlaxman@gmail.com
|
44
|
+
executables:
|
45
|
+
- wkhtmltopdf
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/wkhtmltopdf
|
55
|
+
- htmlToPdf.gemspec
|
56
|
+
- lib/htmlToPdf.rb
|
57
|
+
- lib/htmlToPdf/version.rb
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: html to pdf converter gem
|
82
|
+
test_files: []
|