문제

I have a pdf that is generated using the wicked_pdf gem. My problem is that i see the "download pdf" link in the pdf also. How to remove that link from the rendered pdf? I read about css media types but dont know how to implement that. can anyone help? or is there any other way other than using css media types?

도움이 되었습니까?

해결책

I'm assuming that you are using the pdf format to determine if the user wants a pdf version. You can check if the request format is pdf in your view

<% unless request.format.to_sym == :pdf %>
  <%= link_to 'Download PDF', { format: :pdf } %>
<% end %>

다른 팁

Add the wicked_pdf helper to load a css file

<%= wicked_pdf_stylesheet_link_tag "print" -%>
<div class="export">
 <%= link_to "Download pdf", "http://example.com/download.pdf" %>
</div>

and in your css file you can add code to hide those links under the css selector 'export' using

@media print {
 .export {
  display: hidden;
 }
}

Hope this helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top