1
我已經使用pdfkit.Pdf創建了pdf。但圖像沒有顯示在我的pdf上,並且print_media_type也不起作用。我正在使用rails 4.0.2和ruby 2.0.0。任何人都可以請幫我解決這個問題嗎?我在此附上細節。謝謝。pdfkit的image和print_media_type在軌道上不工作4.0.2
寶石文件:
gem 'pdfkit','0.5.2'
gem 'wkhtmltopdf-binary','0.9.9.1'
gem 'wkhtmltopdf-heroku','1.0.0'
application.css:
@media print {
body {
text-align: justify;
font-size:566px;
background-color: red;
}
}
application.rb中:
require "pdfkit"
config.middleware.use PDFKit::Middleware, :print_media_type => true
配置/初始化/ pdfkit.rb:
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
config.default_options = {
:page_size => 'A4',
:page_height => '2478',
:footer_right => "Page [page] of [toPage]",
:margin_top=>"0.5in",
:margin_right=>"1in",
:margin_bottom=>"0.5in",
:margin_left=>"1in",
:zoom => '1.5',
:disable_smart_shrinking=> false,
:print_media_type => true
}
config.root_url = "//localhost"
end
application.html.erb:
<%= stylesheet_link_tag "application", :media => "all", "data-turbolinks-track" => true %>`
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>`
<body>
<%= image_tag "rails.png", size: "725x150" %>
</body>