wicked-pdf

Wicked pdf not rendering header/footer

爷,独闯天下 提交于 2019-12-05 10:33:40
I am using wicked_pdf for generating pdf from html on my rails project. It is rendering template but I could not manage to print header/footer sections. Below is my code that print only template section render pdf: "pdf_name", layout: 'application', template: 'reports/show', formats: [:html], margin: { top: 10, bottom: 10, left: 10, right: 10 }, disable_javascript: true, show_as_html: params[:debug], header: { html: { template: 'shared/header' }, spacing: 10 }, footer: { html: { template: 'shared/footer' }, spacing: 30, line: true } If I try to use WickedPdf.new.pdf_from_string render_to

WickedPDF missing layout

南笙酒味 提交于 2019-12-05 09:38:09
I have a controller like this: def show @professor = Professor.find(params[:id]) respond_to do |format| format.html format.pdf do render :pdf => "file_name" end end end And a simple view like this: <p>Professor: <%= @professor.first_name %></p> <p>Email: <%= @professor.email if @professor.email %></p> I also have a layout 'application.html.erb'; <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title><%= content_for?(:title) ? yield(:title) : "Myapp" %><

Rails 4 - how to make a link to a PDF file (name.PDF)?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 08:23:32
I am generating PDF files and my link look like this: <%= link_to 'Invoice', display_invoice_path(invoice.id), :format => :pdf %> When I click on this, it takes me to /display_invoice/123456789 (it's an HTML version). In the controller action is following: def display_invoice if params[:invoice_number] @invoice = ... respond_to do |format| format.html format.pdf do #render pdf: '123', # file name render pdf: params[:invoice_number], layout: 'layouts/application.pdf.erb'#, # layout used #show_as_html: params[:debug].present? # allow debuging end end end end and in the routes: get '/display

`undefined method `find_asset' for nil:NilClass`

♀尐吖头ヾ 提交于 2019-12-05 06:03:34
I am using 'rails', '4.2.5' and wicked_pdf gem for generating and downloading PDF, but on Heroku, it's not including css using wicked_pdf_stylesheet_link_tag tag. Heroku error log: ActionView::Template::Error (undefined method 'find_asset' for nil:NilClass) Did I miss any configuration here? To get it work for development and production environment don't use Rails.application.assets.find_asset(logical_file_path).to_s for sprockets-rails version > 3.0.0 but use this (requires gem compass-rails ): CompassRails.sprockets.find_asset(logical_file_path).to_s If you don't use gem compass-rails you

wicked pdf side issue

為{幸葍}努か 提交于 2019-12-04 21:52:20
I'm exporting a table using wicked pdf here is the controller that use wicked def print_invoice respond_to do |format| format.pdf{ send_data render( ####### WICKED CODE ###### :pdf => "invoices", :margin => {:top=> 0,:bottom => 0,:left=> 0,:right => 0}, :orientation => "Landscape", :print_media_type => true,:disable_smart_shrinking => true) ) ####### END WICKED CODE ###### } end end Here is the print view <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table border="1" align="left"> </table> </body> </html> Here is the pdf that I'm getting I

Getting PDF from WickedPDF for attachment via Carrierwave

大城市里の小女人 提交于 2019-12-04 16:31:34
问题 In Rails3, I am using the WickedPDF gem to render a PDF format of one of my models. This is working fine: /invoices/123 returns HTML, /invoices/123.pdf downloads a PDF. In my Invoice model, I am using the state_machine gem to keep track of Invoice status. When an invoice goes from "unbilled" to "billed" state, I would like to grab a copy of the invoice PDF and attach it to the invoice model using CarrierWave. I have the three parts working separately: the controller creates a PDF view, the

Wicked_pdf working fine in development, but not in production

ぐ巨炮叔叔 提交于 2019-12-04 15:47:22
I've been working with wicked_pdf to generate some PDFs in Rails, and it's been working fine in my dev environment, but I get a 500 error (but no specific errors in my log) when I try and generate one on my production environment. The first thing I noticed was that the wkhtmltopdf binary was in a different location on my production box, so I've added the following to my wicked_pdf.rb initializer: if Rails.env == "production" WickedPdf.config = { :exe_path => '/usr/bin/wkhtmltopdf' } end Here's how I'm calling it in my controller: def certificate @inspection = Inspection.find(params[:id])

HTML to PDF with Wicked PDF and letter-spacing issues

China☆狼群 提交于 2019-12-04 07:48:12
Using both 0.79 and 0.7.2 the PDF generated looks slightly different than my original HTML. Adding the show_as_html flag presents it as expected however the inline-styles are being handled differently in the PDF then they are in the HTML preview. Specifically the problem I'm having is with letter-spacing declarations which also have a float not being rendered correctly. So for instance on a right float element which has the letter-spacing, the PDF will space the characters too much and from center such that the text goes partially off the screen rather than bumping further to left for the

Rails3 - wicked_pdf gem, footer issue when calling from action mailer model

ⅰ亾dé卋堺 提交于 2019-12-03 20:33:45
I'm using wicked_pdf pdf_from_string inside an action mailer rails 3 model. The pdf render perfectly doing this: attachments["pdf.pdf"] = WickedPdf.new.pdf_from_string( render_to_string(:pdf => "pdf.pdf",:template => 'documents/show.pdf.erb') ) When I try to pass the option :footer, it does not work with these options: attachments["pdf.pdf"] = WickedPdf.new.pdf_from_string( render_to_string(:pdf => "pdf.pdf", :template => 'pdf/pdf.html.erb', :layout => 'pdfs/pdf', :footer => {:html => {:template => 'pdf/pdf_footer.html.erb', :layout => 'pdfs/pdf'}, :spacing => -65}) ) Note that :footer option

Wicked pdf rendering the last row across two pages

我的梦境 提交于 2019-12-03 15:14:30
问题 I am using wicked_pdf to generate pdfs. The problem i am facing is that, sometimes it displays the last row in the page across two pages. Is there a way to tell wicked_pdf to render the row in next page if it can't fit the entire row in that page or set a limit on the number of rows in a page? Below image is an example of my problem. My options are render :pdf => file_name, :layout => "pdf.html", :disposition => "attachment" 回答1: Since WickedPDF isn't actually creating a table (just rendering