https://github.com/johnantoni/wkhtmltopdf-how-to
wkhtmltopdf for osx
https://github.com/johnantoni/wkhtmltopdf-how-to
Last synced: 6 months ago
JSON representation
wkhtmltopdf for osx
- Host: GitHub
- URL: https://github.com/johnantoni/wkhtmltopdf-how-to
- Owner: johnantoni
- Created: 2014-02-12T17:07:29.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-02-18T18:23:58.000Z (over 12 years ago)
- Last Synced: 2025-10-21T22:39:11.241Z (10 months ago)
- Size: 14.4 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### wkhtmltopdf binary for osx
Currently works on OSX 10.9.1 Mavericks
original article [http://stackoverflow.com/a/10931279](http://stackoverflow.com/a/10931279)
#### install
First download, open and drag to Applications
Then:
cd /usr/local/bin && sudo ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf wkhtmltopdf
#### issues
* will not support images from https locations
* does support background-image replacement
* margin attribute issues
* position: absolute issues
For complex layouts suggest using inline styling or less complex styles, for table data use tables rather than inline lists.
#### headers and footers
header and footer html can be added to the pdf via a meta tag
meta[content="header.html" name="pdfkit-header-html"]
meta[content="footer.html" name="pdfkit-footer-html"]
this won't work straight off with rails as they will be wrapped with **basic auth**, so the easiest way to do this is to host those files on s3 outside the system.
meta[content="http://s3.bucket.com/footer.html" name="pdfkit-footer-html"]
or create the file and run a local webserver to host it
mkdir pdf
cd pdf
vim footer.html
...then
python -m SimpleHTTPServer
...
meta[content="http://localhost:8000/footer.html" name="pdfkit-footer-html"]
note, no css from the parent file will be dragged in to the header/footer, for this you'll have to use inline styling.
#### running
Rather than downloading each file again and again and getting ...(1).pdf, ...(2).pdf you can use wget to download the pdf and overwrite the original
wget -N http://localhost:3000/report/pdf.pdf
=> outputs to pdf.pdf