htmls_to_pdf 0.0.4 → 0.0.5
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/README.markdown +50 -24
- data/examples/get_rails_3_1_release_notes.rb +13 -0
- data/lib/htmls_to_pdf/version.rb +1 -1
- data/license.txt +20 -0
- metadata +6 -4
data/README.markdown
CHANGED
@@ -32,13 +32,39 @@ For information on PDFKit:
|
|
32
32
|
|
33
33
|
## BASIC USAGE
|
34
34
|
|
35
|
-
You will find
|
35
|
+
You will find seven example scripts in the /examples directory.
|
36
36
|
|
37
37
|
After you install HtmlsToPdf and its dependencies, you can write an ordinary Ruby script with the following features:
|
38
38
|
|
39
39
|
### EXAMPLE 1
|
40
40
|
|
41
|
-
Annotated version of /examples/
|
41
|
+
Annotated version of /examples/get\_rails\_3\_1\_release\_notes.rb:
|
42
|
+
|
43
|
+
# require the gem
|
44
|
+
require 'rubygems'
|
45
|
+
require 'htmls_to_pdf'
|
46
|
+
|
47
|
+
# Get 'Rails 3.1 Release Notes' as pdf file
|
48
|
+
# Source: 'http://guides.rubyonrails.org/3_1_release_notes.html'
|
49
|
+
|
50
|
+
# create an empty hash to hold your configuration options
|
51
|
+
config = {}
|
52
|
+
config[:urls] = ['http://guides.rubyonrails.org/3_1_release_notes.html']
|
53
|
+
|
54
|
+
# set a :savedir key with a string value indicating the directory to create
|
55
|
+
# your PDF file in. If the directory does not exist, it will be created
|
56
|
+
config[:savedir] = '~/Tech/Rails/3.1'
|
57
|
+
|
58
|
+
# set a :savename key with a string value indicating the name of the PDF file
|
59
|
+
config[:savename] = 'Rails_3.1_Release_Notes.pdf'
|
60
|
+
|
61
|
+
# create a new HtmlsToPdf object, passing in your hash, and then call create_pdf
|
62
|
+
# on the new object
|
63
|
+
HtmlsToPdf.new(config).create_pdf
|
64
|
+
|
65
|
+
### EXAMPLE 2
|
66
|
+
|
67
|
+
Annotated version of /examples/get\_rubygems\_user\_guide.rb:
|
42
68
|
|
43
69
|
# require the gem
|
44
70
|
require 'rubygems'
|
@@ -69,36 +95,36 @@ Annotated version of /examples/get_rubygems_user_guide.rb:
|
|
69
95
|
# on the new object
|
70
96
|
HtmlsToPdf.new(config).create_pdf
|
71
97
|
|
72
|
-
### EXAMPLE
|
98
|
+
### EXAMPLE 3
|
73
99
|
|
74
|
-
Annotated version of /examples/
|
100
|
+
Annotated version of /examples/get\_coffeescript\_meet\_backbone.rb:
|
75
101
|
|
76
|
-
|
77
|
-
|
102
|
+
require 'rubygems'
|
103
|
+
require 'htmls_to_pdf'
|
78
104
|
|
79
|
-
|
80
|
-
|
105
|
+
# Get 'CoffeeScript, Meet Backbone.js' as pdf file
|
106
|
+
# Source: 'http://adamjspooner.github.com/coffeescript-meet-backbonejs/'
|
81
107
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
108
|
+
config = {}
|
109
|
+
config[:urls] = ['http://adamjspooner.github.com/coffeescript-meet-backbonejs/']
|
110
|
+
(1..5).each do |val|
|
111
|
+
config[:urls] << 'http://adamjspooner.github.com/coffeescript-meet-backbonejs/0' + val.to_s + '/docs/script.html'
|
112
|
+
end
|
113
|
+
config[:savedir] = '~/Tech/Javascript/COFFEESCRIPT/BACKBONE.JS'
|
114
|
+
config[:savename] = 'CoffeeScript_Meet_Backbone.js.pdf'
|
89
115
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
116
|
+
# If a :css key is given with an array value, the CSS files in the array will be used to generate
|
117
|
+
# the PDF document. This allows you to modify the CSS file(s) to, for example, hide HTML headers,
|
118
|
+
# sidebars and footers you do not wish to appear in your PDF.
|
119
|
+
config[:css] = ['http://adamjspooner.github.com/coffeescript-meet-backbonejs/05/docs/docco.css']
|
94
120
|
|
95
|
-
|
96
|
-
|
97
|
-
|
121
|
+
# If a :options key is passed with a hash value, that hash will be passed to wkhtmltopdf.
|
122
|
+
# Many options are available through wkhtmltopdf; see: [the wkhtmltopdf documentation](http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html).
|
123
|
+
config[:options] = {:page_size => 'Letter', :orientation => 'Landscape'}
|
98
124
|
|
99
|
-
|
125
|
+
HtmlsToPdf.new(config).create_pdf
|
100
126
|
|
101
127
|
## LEGAL DISCLAIMER
|
102
128
|
|
103
|
-
Please use at your own risk. I
|
129
|
+
Please use at your own risk. I guarantee nothing about this program.
|
104
130
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'htmls_to_pdf'
|
3
|
+
|
4
|
+
# Get 'Rails 3.1 Release Notes' as pdf file
|
5
|
+
# Source: 'http://guides.rubyonrails.org/3_1_release_notes.html'
|
6
|
+
|
7
|
+
config = {}
|
8
|
+
config[:urls] = ['http://guides.rubyonrails.org/3_1_release_notes.html']
|
9
|
+
|
10
|
+
config[:savedir] = '~/Tech/Rails/3.1'
|
11
|
+
config[:savename] = 'Rails_3.1_Release_Notes.pdf'
|
12
|
+
|
13
|
+
HtmlsToPdf.new(config).create_pdf
|
data/lib/htmls_to_pdf/version.rb
CHANGED
data/license.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2011 by James K. Lavin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htmls_to_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Lavin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-02 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: pdfkit
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- examples/get_coffeescript_meet_backbone.rb
|
71
71
|
- examples/get_exploring_coffeescript.rb
|
72
72
|
- examples/get_python_book.rb
|
73
|
+
- examples/get_rails_3_1_release_notes.rb
|
73
74
|
- examples/get_ruby_book.rb
|
74
75
|
- examples/get_rubygems_user_guide.rb
|
75
76
|
- htmls_to_pdf.gemspec
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- lib/htmls_to_pdf/htmls_to_pdf.rb
|
78
79
|
- lib/htmls_to_pdf/pdfkit_config.rb
|
79
80
|
- lib/htmls_to_pdf/version.rb
|
81
|
+
- license.txt
|
80
82
|
homepage:
|
81
83
|
licenses: []
|
82
84
|
|