-
Notifications
You must be signed in to change notification settings - Fork 24
The installation of the plessl-wkpdf RubyGem fails or gem does not show the latest version of plessl-wkpdf
The plessl-wkpdf gem requires a recent version of RubyGems. You can update your RubyGems installation using:
sudo gem update --system
How can I mirror a whole website and create one PDF file for each HTML page?
wkpdf intentionally does not support mirroring or batch converting on its own, because there are excellent tools that can do this job, for example wget. It is fairly easy to write a script that leverages wget and converts all mirrored files. The following script gives you an idea how this can be done:
#!/usr/bin/ruby
URL = 'http://www.example.com'
system("wget -E --mirror #{URL}")
BASE_DIR = URL
files = `find #{BASE_DIR} -name '*.html'`
files.each do |source_file|
source_file.chomp!
dest_file = source_file.sub(/(.*)\.html?/, '\1.pdf')
system("wkpdf --source #{source_file} --output #{dest_file} --format A5")
end
p.
wkpdf does not work if I specify a —source URL that contains ampersands or other special characters
This problem is not caused by wkpdf but by your shell. You need to use the correct quotation to instruct your shell to pass the URL literally to wkpdf.
For example instead of
wkpdf --source http://www.demo.com/?article=123¤cy=USD --output out.pdf
you would use single quotes like this:
wkpdf --source 'http://www.demo.com/?article=123¤cy=USD' --output out.pdf
For other shells please consult your shell’s man page.