Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to place icons in pdfmake? Is there any Solution #948

Closed
Balaraju1 opened this issue Apr 12, 2017 · 1 comment
Closed

How to place icons in pdfmake? Is there any Solution #948

Balaraju1 opened this issue Apr 12, 2017 · 1 comment

Comments

@Balaraju1
Copy link

Balaraju1 commented Apr 12, 2017

How to place icons in pdfmake? Is there any Solution

@cougarten
Copy link

cougarten commented Apr 12, 2017

I use an icon font. Complicated but possible.

In short:

  • Make a font at http://fontello.com/ or something and download it
  • convert to dataURL (e.g. via http://dataurl.net/#dataurlmaker )
  • add to the fs_js example like the robot font already in there (you can replace or remove the roboto) (strip the "data:application/octet-stream;base64," part from the beginning)
  • define font in js (just defining normal might be enough):
        pdfMake.fonts = {
            Fontello: {
                normal: 'fontello.ttf',
                bold: 'fontello.ttf',
                italics: 'fontello.ttf',
                bolditalics: 'fontello.ttf'
            }
        }
  • add a style for icons:
    icon: { font: 'Fontello' }
  • make a text paragraph:
    { text: '', style: 'icon' }, //icon wifi
  • as the text you copy from the fontello-codes.css from the comments (not the escaped value)

  • if you need an icon within text, you need to nest text objects:
                            text: [
                                    { text: '', style: 'icon' }, //icon gift
                                    " my present"
                                ]

this puts out: "[gift icon] my present"

This was referenced Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants