hm, pdfkit seems quite nice. But in a simple test umlauts weren't displayed correctly with wkhtmltopdf =/
I don't have the time to figure this out for now.
How possible is it to have Rails automatically save a copy of this pdf on the server? I need a confirmation sheet for our folks in the office to use and I'd prefer to not have to do them one at a time if possible.
Though, perhaps the better way to look at this is to render one massive pdf of the index template with some special formatting and page breaks instead of 500 show template pdfs.
Great screencast, once again you were providential:
Just when I was thinking I had to learn Prawn I opened my RSS reader and there was your fresh new tutorial!
Thanks!
"Curious to know if anybody has tried creating a table including images?"
it should work for *any* html, as it uses webkit (the renderer from chrome, safari etc.) to 'display' the html page internally, then draws this into a pdf, in the same way you can export a pdf directly from any program on os x by clicking the PDF button in the print dialog.
"How possible is it to have Rails automatically save a copy of this pdf on the server? I need a confirmation sheet for our folks in the office to use and I'd prefer to not have to do them one at a time if possible."
you could probably create a controller action which uses pdfkit or similar to save a pdf directly to an arbitrary filesystem path. look through its api for a method which returns a File or IO object, it likely uses one internally anyway.
I will very soon be working on wicked_pdf with the intention of bringing it up to date on Rails 3, and Ruby 1.9.2. I might be looking at relying upon PDFKit, if I can do so without losing any of the flexibility of wicked_pdf. I think that will ultimately be better for both projects.
Found out that page-break-before only works if you have a really simple layout, with very few nestings.
Now I only wish "page-break-inside: avoid;" would work...
Got to love PDFs and this should be very powerful. Can't wait to deploy in my app. Just one thing though, sems very straightforward, I followed the steps, in a test 2.3.8 app with a simple scaffold.
Can't get any text to display on the PDF itself, a PDF renders from the show action /show/1.pdf : but it just contains the word "nil" rather than displaying the record as the html view does.
pdfKiT works great for me but only on Rails 3
in Rails 2.3.8 if I do ".pdf" on url it returns empty pdf with "nil". Anybody had that problem ?
Creating from command line works without any problems.
Works fine in irb console but in the real app I get the following error:
Processing PostsController#show to pdf (for 127.0.0.1 at 2010-06-30 22:44:01) [GET]
Parameters: {"id"=>"1"}
Post Load (0.4ms) SELECT * FROM "posts" WHERE ("posts"."id" = 1)
Completed in 13ms (View: 4, DB: 0) | 406 Not Acceptable [http://localhost/posts/1.pdf]
One note: instead of #pdf_link, maybe you could have used .no_print. It seems likely that there will be other items you don't want to print - using an id tag for that one seems pretty heavy.
For everyone getting only "nil" rendered, check your logs. Likely it will say it want's a genereic template such as show.erb.
The patch quoted above which is at http://github.com/perenecabuto/PDFKit/commit/c61f8d683c2894c2cfecf08b43707c63514c4c9f
might work but it's not yet in the master branch AFAICT.
to add page numbers, you can add some spans to the header HTML that will be replaced, see: http://madalgo.au.dk/~jakobt/wkhtmltopdf-0.10.0_beta4-doc.html#Headers%20And%20Footer%20Options. Setting the header is easier using wicked_pdf.
I've been using Prawn, but find it too time consuming. I installed PDFKIT and can run my page if I type in the URL.pdf, but when using the link_to... :format => pdf, it still launches the Prawn formatted doc.
I've removed the pdf.prawn doc, the environment.rb requirement, as well as the vendor/plugin contents, but it still launches the prawn doc. WTF?
I tried uninstalling the Prawn gem, but phusion won't start my app at all.
So...where else are these prawn files hiding that won't let PDFKIT take over?
@bingobob: I was also concerned that every page can be rendered as .pdf. I only have one page that makes sense. Instead of doing the middleware step, I think I can just call: `wkhtmltopdf --page-width 8.5in --page-height 11.0in http://my.domain.com/my/url output.pdf` from my controller in the one place it is needed.
If you don't want to use the middleware for rendering (this might be the case if you want add a custom filename to the send_data method), you can do something like this:
well... what about wkhtmltopdf-qt ?
The gem says it has to be installed... and this part is very much more complicated.
Does anyone have experienced it ?
I have been following and using railscasts for the last 6 months now and without them I would lost. Thank you so much Ryan for all the time and effort you put into your excellent casts
I'm having a few problems following along with this cast though and in particular with the installation of wkhtmltopdf. I was wondering if anyone else has experienced similar problems or has any clues as to what is going wrong. It is a rails 3 app, 1.9.2 running on snow leopard. I use rvm
I added PDFkit to my gemfile and the appropriate config options to my application.rb. I then tried to see if a could get a pdf version of one of the pages in my app and I got the following action controller exception
No wkhtmltopdf executable found at /usr/local/bin/wkhtmltopdf
>> Install wkhtmltopdf by hand or try running `pdfkit --install-wkhtmltopdf`
I tried installing using the command
pdfkit --install-wkhtmltopdf
this didn't go smoothly and I had to add the directory and change some permissions but I got it installed. I'm still getting a permission denied exception but as far as I can tell the file is rwx for all
It kind of feels like I have drifted down the wrong path completely with this. If anyone has any pointers they would be greatly appreciated
Nice tutorial, great for quick PDF's, I would still use Prawn for some of the letters I produce.
Will use this way of creating PDF's on the fly, a PDF icon/link in the application layout will allow any page (current) to be saved which is a neat feature.
Great screencast, but half of my views are rendered in pdf, I don't know why? I set config.middleware.use PDFKit::Middleware, {}, :only => %r[^/invoices/show] in application.rb
The problem from posts 63 and 64 seems to be a problem with PDFKit 0.5.0. I changed my gemfile to use PDFKit 0.4.6 and the problem was gone. found the fix here "github.com/jdpace/PDFKit/issues#issue/66".
BTW thanks for all the bad ass casts Ryan. I've learned more from you than all the rails books and tutorials I've gone through combined. You freakin RULE!!!
Does anyone have any suggestions on how I would tell my app to not load any pictures and javascript files when rendering the pdf's? Perhaps in an initializer or something?
As many others have said without your efforts I would have spent way too much time on this - if anyone gets prawn up and working with Rails 3X let me know.
Everything is ok in development environment, having some problems in production: while the corresponding html (with its css) is exactly as it's supposed to be, the .pdf version seems to ignore css rules. Any suggestions?
Hi. This gem is beautifull. But I have som problem. When I try to get pdf I see only clear site with nothing. I have installed gem and I have written all definitions like require but nothing helps. Please give me some advice. (rails 3.1, ruby 1.9.2 on windows maschine)
Does anyone have any suggestions on how I would start content always from next page when it's breaking between pages.
Example - I have list of photos which i am exporting to pdf.
While listing some photos are cutting in two parts first is coming in one page and remaining coming on other page so how we start photo which is breaking in two part should always display from starting of the page
Very nice. I have to mention that PDFKit is also used to generate pdf files from html strings as follows:
html = "< h1>pla pla pla< /h1>"
kit = PDFKit.new(html, :page_size => 'Letter')
pdf = kit.to_pdf
file = kit.to_file("path/to/pdf/with/pdf_name.pdf")
Note: this might throw an error of missing wkhtmltopdf even when you unstall wkhtmltopdf, and I found out that you still need to install ghostscript to you computer (mine is Mac 10.7.4).
I am using PDFKit on Mac 10.7 and powify as my local development server. I tried installing the software as described in the cast but am getting the following error when running through my app.
If I run through the command line I can generate pdf's. If anyone has an idea on how to fix this that would be great. I'm really new to rails so a detailed explanation would be helpful.
I had to run unicorn as the web server with multiple workers, I couldn't get pow to serve the pdf even if I changed the number of workers pow was using.
I have followed the Ryan's code and copy-pasted all the codes, but
the css style @media print{} is not affecting to the pdf file so I cannot hide the link. I have tested with Chrome, IE and Firefox. Link disappears when I click browser's print preview.
Thanks very much for the episodes and best wishse.
and what about epub?
any gem preferences?
thanks for your excellent work.
Ryan, great job as usual. I was already planning to check out those gems during these days so the timing of this screencast is just perfect.
Awesome with a capital A, I have been waiting for a library like this for ages.
Ryan,
Great stuff. The episode came sooner than I expected.
Thanks.
- Jermaine
A great gem! I love that it can be used as middleware! Thanks so much for the screencasts!
This is fantastic. Prawn drives me nuts.
hm, pdfkit seems quite nice. But in a simple test umlauts weren't displayed correctly with wkhtmltopdf =/
I don't have the time to figure this out for now.
How possible is it to have Rails automatically save a copy of this pdf on the server? I need a confirmation sheet for our folks in the office to use and I'd prefer to not have to do them one at a time if possible.
Though, perhaps the better way to look at this is to render one massive pdf of the index template with some special formatting and page breaks instead of 500 show template pdfs.
Curious to know if anybody has tried creating a table including images?
really really cool screencast and very nice thing this pdfkit :)
Prawn for clean structures
PDFKit for fancy looks ;)
Great screencast, once again you were providential:
Just when I was thinking I had to learn Prawn I opened my RSS reader and there was your fresh new tutorial!
Thanks!
"Curious to know if anybody has tried creating a table including images?"
it should work for *any* html, as it uses webkit (the renderer from chrome, safari etc.) to 'display' the html page internally, then draws this into a pdf, in the same way you can export a pdf directly from any program on os x by clicking the PDF button in the print dialog.
"How possible is it to have Rails automatically save a copy of this pdf on the server? I need a confirmation sheet for our folks in the office to use and I'd prefer to not have to do them one at a time if possible."
you could probably create a controller action which uses pdfkit or similar to save a pdf directly to an arbitrary filesystem path. look through its api for a method which returns a File or IO object, it likely uses one internally anyway.
actually if you only need to do it once/rarely a rake task would be better than mucking up your controllers and routing
Hi again Ryan,
Can't really make page-break-before work, it's always cutting my tables...
What version of wkhtmltopdf are you using?
Thanks for plug, Mr. Bates!
I will very soon be working on wicked_pdf with the intention of bringing it up to date on Rails 3, and Ruby 1.9.2. I might be looking at relying upon PDFKit, if I can do so without losing any of the flexibility of wicked_pdf. I think that will ultimately be better for both projects.
Found out that page-break-before only works if you have a really simple layout, with very few nestings.
Now I only wish "page-break-inside: avoid;" would work...
Got to love PDFs and this should be very powerful. Can't wait to deploy in my app. Just one thing though, sems very straightforward, I followed the steps, in a test 2.3.8 app with a simple scaffold.
Can't get any text to display on the PDF itself, a PDF renders from the show action /show/1.pdf : but it just contains the word "nil" rather than displaying the record as the html view does.
Sorry if I'm being dense, any ideas?
page-break-avoid does not yet work in wkhtmltopdf. it's because this would require heavy changes in webkits rendering ...
If page-breake-before does not work. Try doing "clear: both; page-break-before: always; display: block;" ...
The clearing should do the trick.
Anyone knows how to display the current page number and the total number of pages?
Same problem as Rupert Fisher... I obtain a 'nil' blank page every time :(
Thank you for a great cast.
pdfKiT works great for me but only on Rails 3
in Rails 2.3.8 if I do ".pdf" on url it returns empty pdf with "nil". Anybody had that problem ?
Creating from command line works without any problems.
Many thanks.
Works fine in irb console but in the real app I get the following error:
Processing PostsController#show to pdf (for 127.0.0.1 at 2010-06-30 22:44:01) [GET]
Parameters: {"id"=>"1"}
Post Load (0.4ms) SELECT * FROM "posts" WHERE ("posts"."id" = 1)
Completed in 13ms (View: 4, DB: 0) | 406 Not Acceptable [http://localhost/posts/1.pdf]
Anybody know who to get this to work?
Any help would be greatly appreciated J.
Thanks for this. Awesome alternatives to the expensive princeXML.
I am having the same error that marek(comment 26).
Environment:
Rails 2.3.8 con bundle.
wkhtmltopdf in '/usr/local/bin'
And the error:
406 Not Acceptable [http://localhost/whatever.pdf] and no output.
Any ideas?
Thank you
Hi, Great screencast.
having the same problem that 26 and 66
Can anyone give a hand?
To solve the problem with Rails 2.3++ look at http://github.com/perenecabuto/PDFKit/commit/c61f8d683c2894c2cfecf08b43707c63514c4c9f it works for me.
Hello Ryan,
thank you for another great episode. You can actually obtain the url text using css:
http://gist.github.com/465259
Of course, it's better to put that into a print.css stylesheet. I am not sure if it works in IE6, BTW.
Hi Ryan,
I was desperately looking for a working example of PDFKIT.
This is great!!!!
Thanks a lot!!!!!
Great episode; I'll have to check pdfkit out.
One note: instead of #pdf_link, maybe you could have used .no_print. It seems likely that there will be other items you don't want to print - using an id tag for that one seems pretty heavy.
But that's a nit! Thank again.
Thank god for the creation of ryanb ! ;) you save my ass every time, bro.
For everyone getting only "nil" rendered, check your logs. Likely it will say it want's a genereic template such as show.erb.
The patch quoted above which is at http://github.com/perenecabuto/PDFKit/commit/c61f8d683c2894c2cfecf08b43707c63514c4c9f
might work but it's not yet in the master branch AFAICT.
Has anyone been able to solve the 406 error on Rails 2.3.8 ?
Hi Fredrik,
to add page numbers, you can add some spans to the header HTML that will be replaced, see: http://madalgo.au.dk/~jakobt/wkhtmltopdf-0.10.0_beta4-doc.html#Headers%20And%20Footer%20Options. Setting the header is easier using wicked_pdf.
I've been using Prawn, but find it too time consuming. I installed PDFKIT and can run my page if I type in the URL.pdf, but when using the link_to... :format => pdf, it still launches the Prawn formatted doc.
I've removed the pdf.prawn doc, the environment.rb requirement, as well as the vendor/plugin contents, but it still launches the prawn doc. WTF?
I tried uninstalling the Prawn gem, but phusion won't start my app at all.
So...where else are these prawn files hiding that won't let PDFKIT take over?
@bingobob: I was also concerned that every page can be rendered as .pdf. I only have one page that makes sense. Instead of doing the middleware step, I think I can just call: `wkhtmltopdf --page-width 8.5in --page-height 11.0in http://my.domain.com/my/url output.pdf` from my controller in the one place it is needed.
If you don't want to use the middleware for rendering (this might be the case if you want add a custom filename to the send_data method), you can do something like this:
format.pdf {
html = render_to_string(:action => "show.html.erb")
kit = PDFKit.new(html)
kit.stylesheets << "#{Rails.root}/public/stylesheets/print.css"
send_data kit.to_pdf, :filename => "Your-custom-filename.pdf", :type => 'application/pdf'
}
How to cache the PDF using Rails page caching and PDFKit
1. Disable the PDFKit middleware so that your controller handles the generation of the PDF.
2. Register PDF as a mime-type in environment.rb:
Mime::Type.register "application/pdf", :pdf
3. In your controller, cache pages just like normal with caches_page :show
4. create a format.pdf call in your respond_to block and init a new PDFKit object, pass in the url to the current action and call to.pdf on it.
respond_to do |format|
format.html # show.html.erb
format.pdf { render :text => PDFKit.new( post_url(@post) ).to_pdf }
end
Now in your cache directory you'll create two cache files - one .html and one .pdf.
well... what about wkhtmltopdf-qt ?
The gem says it has to be installed... and this part is very much more complicated.
Does anyone have experienced it ?
On windows there is an exe installer. On mac and linux the install prosses is well documented here and here go to wiki on the last one
Not work with cyrillic's symbols. Help me.
I have been following and using railscasts for the last 6 months now and without them I would lost. Thank you so much Ryan for all the time and effort you put into your excellent casts
I'm having a few problems following along with this cast though and in particular with the installation of wkhtmltopdf. I was wondering if anyone else has experienced similar problems or has any clues as to what is going wrong. It is a rails 3 app, 1.9.2 running on snow leopard. I use rvm
I added PDFkit to my gemfile and the appropriate config options to my application.rb. I then tried to see if a could get a pdf version of one of the pages in my app and I got the following action controller exception
No wkhtmltopdf executable found at /usr/local/bin/wkhtmltopdf
>> Install wkhtmltopdf by hand or try running `pdfkit --install-wkhtmltopdf`
I tried installing using the command
pdfkit --install-wkhtmltopdf
this didn't go smoothly and I had to add the directory and change some permissions but I got it installed. I'm still getting a permission denied exception but as far as I can tell the file is rwx for all
It kind of feels like I have drifted down the wrong path completely with this. If anyone has any pointers they would be greatly appreciated
I found a way around the problem I described in 107 which I describe here
http://www.ruby-forum.com/topic/218049#945995
It work great .
but It's seems not support chinese in Ubuntu server 10.04 LTS.
any one help?
Nice tutorial, great for quick PDF's, I would still use Prawn for some of the letters I produce.
Will use this way of creating PDF's on the fly, a PDF icon/link in the application layout will allow any page (current) to be saved which is a neat feature.
Good Job!
Help me
/!\ FAILSAFE /!\ Thu Dec 02 14:02:38 -0500 2010
Status: 500 Internal Server Error
undefined method `match' for nil:NilClass
/usr/lib/ruby/gems/1.8/gems/pdfkit-0.4.6/lib/pdfkit/middleware.rb:12:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:99:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:106:in `call'
/sites/highliner.com/releases/20101202185932/config/initializers/mongrel.rb:62:in `dispatch_cgi'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
/sites/highliner.com/releases/20101202185932/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Great screencast, but half of my views are rendered in pdf, I don't know why? I set config.middleware.use PDFKit::Middleware, {}, :only => %r[^/invoices/show] in application.rb
Please help.
All my /edit views are rendering as pdf's too - similar to #63 -
Anyone have an idea for this??
The problem from posts 63 and 64 seems to be a problem with PDFKit 0.5.0. I changed my gemfile to use PDFKit 0.4.6 and the problem was gone. found the fix here "github.com/jdpace/PDFKit/issues#issue/66".
BTW thanks for all the bad ass casts Ryan. I've learned more from you than all the rails books and tutorials I've gone through combined. You freakin RULE!!!
Does anyone have any suggestions on how I would tell my app to not load any pictures and javascript files when rendering the pdf's? Perhaps in an initializer or something?
Just a quick note --
Version 0.5.0 of Webkit has problems with both Webrick and Passenger ... after a pdf page is requested, all further requests come as PDFs too.
there's a fix here:
https://github.com/huerlisi/PDFKit.git
or version 0.4.6 seems to be working for others.
As many others have said without your efforts I would have spent way too much time on this - if anyone gets prawn up and working with Rails 3X let me know.
im using rails 3.1 rc2 and this error appear & hangs the webrick web server.
The switch --print-media-type, is not support using unpatched qt, and will be ignored.
has any1 encounter this issue?
Is there any way to send the PDF generation to a background process like delayed job?
Everything is ok in development environment, having some problems in production: while the corresponding html (with its css) is exactly as it's supposed to be, the .pdf version seems to ignore css rules. Any suggestions?
Hi. This gem is beautifull. But I have som problem. When I try to get pdf I see only clear site with nothing. I have installed gem and I have written all definitions like require but nothing helps. Please give me some advice. (rails 3.1, ruby 1.9.2 on windows maschine)
Sounds like a Rails 3.1 issue with the asset pipeline and threading: https://github.com/jdpace/PDFKit/issues/110
Is there a way to get a pdf file with 300dpi using PDFKit?
There appears to be a problem with pdfkit and the Rails 3.1+ asset pipeline. It still appears to be an open issue.
I ended up switching to wicked_pdf and it appears to handle stylesheets fine (but be aware that you need to use their stylesheet include tag).
InvalidByteSequenceError using pdfkit jruby 1.6.7-2
Does anyone have any suggestions on how I would start content always from next page when it's breaking between pages.
Example - I have list of photos which i am exporting to pdf.
While listing some photos are cutting in two parts first is coming in one page and remaining coming on other page so how we start photo which is breaking in two part should always display from starting of the page
Very nice. I have to mention that PDFKit is also used to generate pdf files from html strings as follows:
html = "< h1>pla pla pla< /h1>"
kit = PDFKit.new(html, :page_size => 'Letter')
pdf = kit.to_pdf
file = kit.to_file("path/to/pdf/with/pdf_name.pdf")
Note: this might throw an error of missing wkhtmltopdf even when you unstall wkhtmltopdf, and I found out that you still need to install ghostscript to you computer (mine is Mac 10.7.4).
Hello,
I am using PDFKit on Mac 10.7 and powify as my local development server. I tried installing the software as described in the cast but am getting the following error when running through my app.
command failed: "/usr/local/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--ignore-load-errors" "--quiet" "-" "-"
If I run through the command line I can generate pdf's. If anyone has an idea on how to fix this that would be great. I'm really new to rails so a detailed explanation would be helpful.
Thanks
Eric
I had to run unicorn as the web server with multiple workers, I couldn't get pow to serve the pdf even if I changed the number of workers pow was using.
I also had to use Unicorn to get the pdf to load.
However, PDFKit leaves me with this dilema:
Option 1:
Enable CSS to show up on page. Unfortunately, no text / content will show up!
Option 2:
Do not have any CSS on the page. Now the text / content shows up!
Oh joy. Hoping Prawn will leave me with more desirable options...
Hello Ryan,
it works very nice but the problem is that images are not shown in pdf file generated by this gem. How can i solve this problem.
please help.
Thanks
Hello,
I have followed the Ryan's code and copy-pasted all the codes, but
the css style @media print{} is not affecting to the pdf file so I cannot hide the link. I have tested with Chrome, IE and Firefox. Link disappears when I click browser's print preview.
I am using rails 4.0 and ruby 2.0
Thanks for any help!
How did you do it to not get a hang when rendering the pdf? Are the application.css styles applied to your pdf?
I've been stuck in this a long time.
Same. Tomas do you find the solution to this?
Same here. Hit a dead end because of this.
Did you guys figure it out? I'm stuck too!
Also guys, I'm stucked with rails render hang up
Hi Rayn,
I got one issues. pdf kit is support custom fonts. I tried one of project its not taking custom fonts'
here is example:
@font-face {
font-family: 'oswald_regularregular';
src: url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.eot" %>);
src: url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.eot?#iefix" %>) format('embedded-opentype'),
url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.woff2" %>) format('woff2'),
url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.woff" %>) format('woff'),
url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.ttf" %>) format('truetype'),
url(<%= "#{Rails.root}"+"/app/assets/fonts/oswald-regular.svg#oswald_regularregular" %>) format('svg');
font-weight: normal;
font-style: normal;
}
Can you please help us
superb post