README.md in pdfkit-0.8.4.1 vs README.md in pdfkit-0.8.4.2
- old
+ new
@@ -12,11 +12,11 @@
1. Install by hand (recommended):
<https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF>
-2. Try using the `wkhtmltopdf-binary` gem (mac + linux i386)
+2. Try using the `wkhtmltopdf-binary-edge` gem (mac + linux i386)
```
gem install wkhtmltopdf-binary
```
*Note:* The automated installer has been removed.
@@ -32,11 +32,11 @@
# Save the PDF to a file
file = kit.to_file('/path/to/save/pdf')
# PDFKit.new can optionally accept a URL or a File.
-# Stylesheets can not be added when source is provided as a URL of File.
+# Stylesheets can not be added when source is provided as a URL or File.
kit = PDFKit.new('http://google.com')
kit = PDFKit.new(File.new('/path/to/html'))
# Add any kind of option through meta tags
PDFKit.new('<html><head><meta name="pdfkit-page_size" content="Letter"')
@@ -114,20 +114,27 @@
config.middleware.use PDFKit::Middleware, {}, :except => [%r[^/prawn], %r[^/secret]]
# conditions can be strings (either one or an array)
config.middleware.use PDFKit::Middleware, {}, :except => ['/secret']
```
+**With conditions to force download**
+```ruby
+# force download with attachment disposition
+config.middleware.use PDFKit::Middleware, {}, :dispositon => 'attachment'
+# conditions can force a filename
+config.middleware.use PDFKit::Middleware, {}, :dispositon => 'attachment; filename=report.pdf'
+```
**Saving the generated .pdf to disk**
Setting the `PDFKit-save-pdf` header will cause PDFKit to write the generated .pdf to the file indicated by the value of the header.
For example:
```ruby
headers['PDFKit-save-pdf'] = 'path/to/saved.pdf'
```
-Will cause the .pdf to be saved to `path/to/saved.pdf` in addition to being sent back to the client. If the path is not writable/non-existant the write will fail silently. The `PDFKit-save-pdf` header is never sent back to the client.
+Will cause the .pdf to be saved to `path/to/saved.pdf` in addition to being sent back to the client. If the path is not writable/non-existent the write will fail silently. The `PDFKit-save-pdf` header is never sent back to the client.
## Troubleshooting
* **Single thread issue:** In development environments it is common to run a
single server process. This can cause issues when rendering your pdf
@@ -138,16 +145,16 @@
This is usually not an issue in a production environment. To get
around this issue you may want to run a server with multiple workers
like Passenger or try to embed your resources within your HTML to
avoid extra HTTP requests.
-
+
Example solution (rails / bundler), add unicorn to the development
group in your Gemfile `gem 'unicorn'` then run `bundle`. Next, add a
file `config/unicorn.conf` with
-
+
worker_processes 3
-
+
Then to run the app `unicorn_rails -c config/unicorn.conf` (from rails_root)
* **Resources aren't included in the PDF:** Images, CSS, or JavaScript
does not seem to be downloading correctly in the PDF. This is due
to the fact that wkhtmltopdf does not know where to find those files.