Show fa-icons in print and export

Show fa-icons in print and export

angekoufangekouf Posts: 14Questions: 4Answers: 0
edited January 2017 in Free community support

I am using html 5 exporter and it is working as expected for fields with columns with simple text format (no html formatting).
For columns that display fa-icons instead of text the column shows empty during print and export.
For example this rendered column (that displays 3 stars)

<td>
    <i class="fa fa-star" aria-hidden="true"></i>
    <i class="fa fa-star" aria-hidden="true"></i>
    <i class="fa fa-star" aria-hidden="true"></i>
</td>

shows empty during print/export. Those functions only print the inner text of the cell (which is obviously empty)
Is there a way to include the html formatting for a column during print/export?

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin
    Answer ✓

    The HTML is stripped by default. You'd need to use the stripHtml option in the buttons.exportData() method. Which in turn you can access through the exportOptions of print.

    Allan

  • ttse23ttse23 Posts: 10Questions: 3Answers: 0

    please see this example
    https://jsfiddle.net/ttse23/ruvvb2rc/

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin

    With the PDF, FontAwesome won't work since its icons aren't included in the font file that the pdfmake library that is being used uses. They provide details on how you can create your own font file if you want.

    The Excel aspect would require a new style to be added that will use FontAwesome as the font for those cells and FontAwesome would need to be installed as a font on your users computers.

    In short, there is no easy way to do what you are looking for.

    It should work okay for print though.

    Allan

  • angekoufangekouf Posts: 14Questions: 4Answers: 0
    edited January 2017

    Thank you @allan . stripHtml worked like a charm for printing.
    Is it possible to use render function to print different value (a simle number for the stars mentioned above) if the type = export for instance?

    @ttse23 Nice example for title but did nothing for stripping html code in table body during print. Thank you anyway for your help

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin
    Answer ✓

    Yes :smile:.

    Allan

  • angekoufangekouf Posts: 14Questions: 4Answers: 0

    That worked perfectly @allan . Not as pretty as font-awsome icons but it is better than empty cells :blush: Including a custom font is way too much work for now.
    Maybe I will do it later and will upload it here if I have the time

This discussion has been closed.