2

I am using pdfkit gem for generating the pdf file. I am using stylesheets for changing the style with

  pdf = PDFKit.new(html, orientation: 'Landscape')
  pdf.stylesheets << File.join(Rails.root, 'app', 'assets', 'stylesheets', 'pdf.css')

In my app/assets/stylesheets/pdf.css, I have:

  a {
    cursor: default;
    color: black;
  }

In my html I have a simple link_to tag. I want to disable the link in the pdf, however, the above code makes the text of the link black but the cursor is still pointer. Also, I tried pointer-events: none. This also doesn't seem to work. Can anyone please help me with this issue?

Note: I found similar issue in this github issue, but was not able to find an answer here.

Sadiksha Gautam
  • 5,032
  • 6
  • 40
  • 71

1 Answers1

1

I had same problem and I was not able to find a perfect solution for this. This is a simple method I did and it worked...

<span class="show_in_html">
  <%= link_to(home_url) do %>
    <%=t('header.home')%>
  <% end %>
</span>

<span class="show_in_pdf">
   <%=t('header.home')%>
</span> 

In home.css

.show_in_html{display:block}

.show_in_pdf{display:none;}

In pdf.css

.show_in_pdf{display:block !important;}

.show_in_html{display: none !important;}