pdf make 1

by Martin Murciego

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.20/pdfmake.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.20/vfs_fonts.js"></script>
<h4 id="toto">
HEHEHHE
</h4>

JavaScript

var toto = $("#toto").text();
alert(toto)

var docDefinition = {
   	pageSize: {width:89/0.3528,height:36/0.3528},
     pageMargins: [ 3, 0,  3 ,0],
	content: [
		{ 
						style: 'nutriTable',
						table: {
								widths: [ '25%', '25%', '25%','25%' ],
								headerRows: 2,
								// keepWithHeaderRows: 1,
								body: [
										[{ text: 'nutritional values medio', style: 'tableHeader', colSpan: 4, alignment: 'center' }, {}, {},{}],
										[{ text: 'per 100g (%*) ', style: 'tableHeader', alignment: 'right',colSpan:2 }, {}, { text: 'per 100g (%*) ', style: 'tableHeader', colSpan:2,alignment: 'right' },{}],
										[ { text:'toto', style: 'header'}, '23 (9,3%)', { text:'carboidrati', style: 'header'},'23g (45%)' ],
										[ 'hahaha', 'value 2', { text:'di cui zuccheri', style: 'header'},'blabla' ],
										[ { text:' Grassi', style: 'header'}, 'value 2', { text:'Proteine', style: 'header'} ,'blabla'],
										[ { text:' di cui stauri', style: 'header'}, 'value 2', { text:'Sale', style: 'header'},'blabla' ],
										[ { text: '* assunzione di riferimento di un adulto medio (8400 kj/2000 kcal)', style: 'tableHeader', colSpan: 4, alignment: 'left' }, {}, {},{} ]
									
								]
						}
				}
	],
	styles: {
		nutriTable: {
			margin: [0,0,0,0]
		},
		tableHeader: {
			fontSize: 8
		}
	},
	defaultStyle: {
        fontSize:8
		// alignment: 'justify'
	}
 };


// open the PDF in a new window
 //pdfMake.createPdf(docDefinition).open();

 // print the PDF (temporarily Chrome-only)
 //pdfMake.createPdf(docDefinition).print();

 // download the PDF (temporarily Chrome-only)
 pdfMake.createPdf(docDefinition).download('optionalName.pdf');