Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

put checkmark in pdfmake report

Tags:

pdfmake

i have a project to print out the working report. i got trouble when putting check mark inside pdfmake generated report i follow some instructions from below link :

  • https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side
  • https://github.com/bpampuch/pdfmake/issues/948

i already follow all the instructions there but my fontelo nor fontawesome icon show up in my report. while using fontawesome. the icon show square block no the real icon. hope someone can help me figure this out thanks

like image 450
Jsnow Avatar asked Apr 19 '17 02:04

Jsnow


3 Answers

Maybe you could include some code (a minimal docDefinition, and the printer part).

My code, using fontawesome to display checkboxes/radio icons :

The printer part :

var fonts = {
    Roboto: {
        normal: 'assets/fonts/Roboto-Regular.ttf',
        bold: 'assets/fonts/Roboto-Medium.ttf',
        italics: 'assets/fonts/Roboto-Italic.ttf',
        bolditalics: 'assets/fonts/Roboto-MediumItalic.ttf'
    },
    FontAwesome: {
        normal: 'assets/fonts/fontawesome-webfont.ttf'
    }
  };
// ...
var printer = new PdfPrinter(fonts);

And the docDefinition. You can try using the unicode code :

var dd = {
  content: { text: "\uf046   ", style: 'fontawesome' },
  styles: {
    fontawesome: {
      'font': 'FontAwesome',
      'color': "#656565"
    }
  }
}
like image 83
arnaud del. Avatar answered Oct 29 '22 08:10

arnaud del.


Maybe this ASCII value could work for you? √√√√√√√√

  • Mac: Option + v
  • Windows10: Alt + 251

You will get this symbol √ which is similar to the tick checkmark.

  • http://pdfmake.org/playground
  • Look at the Extended ASCII Codes section: http://www.asciitable.com/
{
   text: '√',
   absolutePosition: { x: 21, y: 293 }
}

Happy Coding! :)

like image 43
Mr. Dang Avatar answered Oct 29 '22 10:10

Mr. Dang


you can use canvas to draw the square for checkmark as below

canvas: [
            {
                type: 'polyline',
                lineWidth: 1,
                closePath: true,
                points: [{ x: 0, y: 0}, { x: 8, y: 0 }, { x: 8, y: 8 }, { x: 0, y:8 }]
            }
        ]

and then use it with column to make it look like checkbox

like image 3
Ramesh Maharjan Avatar answered Oct 29 '22 08:10

Ramesh Maharjan