Search code examples
ruby-on-railsckeditorpdf-generationprawnprawnto

Usage of html_safe attribute in Prawn PDF syntax


I'm rendering the PDF data from the output of CK editor (What you see is what you get editor). The output from that editor would be included with all the HTML, CSS tags in the content. For that I had used 'html_safe' attribute in the show page. But when I try to use the same attribute in the PDF prawn syntax its not working. Can someone please guide me how to get the pure content without all the HTML tags in Prawn PDF?

Thanks in advance.


Solution

  • After a long a Google search I finally got an answer which I wish to share with you.

    As html_safe is the action view method in rails, It can not be used in ruby syntax of Prawn pdf.

    So for that we can use:

    ActionView::Base.full_sanitizer.sanitize(@string)
    

    http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-strip_tags