3

I have a problem with my CSS of wicked pdf Everything work in local but it not find the pdf.css in production

ActionView::Template::Error (The asset "components/pdf.css" is not present in the asset pipeline.):
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<%= wicked_pdf_stylesheet_link_tag 'components/pdf.css' %>
 </head>
<body>
<%= yield %>

My pdf.html.erb

<!doctype html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <%= wicked_pdf_stylesheet_link_tag 'components/pdf' %>
  </head>
  <body>
      <%= yield %>
  </body>
</html>

my components/pdf.css

.document-pdf {
  background-image: asset-data-url("fond.png");
  background-size: 23cm 13cm;
  background-color: white;
  background-repeat: no-repeat;
  background-position: 50% 70%;
  font-family: "Helvetica Neue", Helvetica;
}
Antoine Wako
  • 145
  • 1
  • 17

2 Answers2

5

Have you added pdf.css to precompiled assets in initializers/assets.rb?

Rails.application.config.assets.precompile += ['pdf.css']
Tomasz Giba
  • 507
  • 1
  • 8
  • 22
0

Every issue could be happen because of different reasons. So I wanted to share mine if somebody have possibly same situation.

  • Ruby updated at some point (this error happened after update). and we were getting 'pdf.css not find error' on the heroku console.

we run gem update sass-rails gem update wicked_pdf and gem update wkhtmltopdf-binary on the heroku console.

best

greenridinghood
  • 629
  • 5
  • 7