const potongTeks = function(teks, panjangMaks) { if (teks.length <= panjangMaks) { return teks; } else { return teks.slice(0, panjangMaks) + "..."; } } const checkData = function(a,b){ if(typeof a === 'object'){ if(a[b] != undefined){ return potongTeks( a[b] , 38); } return '-'; } return '-'; } const jk = function(a,b){ if (typeof a === 'object') { if (a[b] != undefined) { if(a[b] === 'L'){ return 'Laki laki' } return 'Perempuan'; } return '-'; } return '-'; } window._pdfMakeKTA = function (a) { var col = []; let ln = Math.ceil(a.length / 3); let numStart = 0; for (let i = 0; i < ln; i++) { let nd = []; let data = {}; if ( a[numStart] != undefined ){ data = a[numStart]; } numStart++; for (let q = 0; q < 3; q++) { nd.push([ { table: { widths: ['*'], body: [ [ [ { text: 'BIODATA ANGGOTA', style: ['center', 's2', 'bold'] } , { layout: 'lightHorizontalLines' , table: { widths: [69, 3, '*'] , body: [ [{ text: 'NO.INDUK', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: '', style: ['s1'] }] , [{ text: 'NAMA', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data,'nama'), style: ['s1'] }] , [{ text: 'TGL. LAHIR', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: tanggal(checkData(data,'tgllahir')).sekarang , style: ['s1'] }] , [{ text: 'JENIS KELAMIN', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: jk(data,'jk'), style: ['s1'] }] , [{ text: 'TELP', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data,'telp'), style: ['s1'] }] , [{ text: 'UNIT KERJA', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data,'unitkerja'), style: ['s1'] }] , [{ text: 'ALAMAT RUMAH', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: checkData(data,'alamat'), style: ['s1'] }] , [{ text: 'TAHUN MASUK', style: ['s1'] }, { text: ':', style: ['s1'] }, { text: tanggal(checkData(data, 'masuk')).sekarang, style: ['s1'] }] ] } } , { text: 'Keterangan', style: ['s2', 'bold'] } , { layout: 'noBorders' , table: { widths: [3, '*'] , body: [ [{ text: '-', style: ['s1'] }, { text: 'Mohon dikoreksi ulang untuk kejelasan data.', style: ['s1'] }] , [{ text: '-', style: ['s1'] }, { text: 'Untuk unit kerja Guru TK/SD/SMP/SMA, harap ditulis lengkap nama sekolahannya.', style: ['s1'] }] , [{ text: '-', style: ['s1'] }, { text: 'Apabila terdapat kesalahan data, maka bisa di konfirmasi ke nomor Warpeka ( 085 748 055 474 ).', style: ['s1'] }] ] } } ] ], ] } } ]) } col.push({ columns:nd, columnGap: 5 }) } var docDefinition = { pageOrientation: 'landscape', pageMargins: [5, 5, 5, 5], content: col , styles: { s1: { margin: [5, 0], fontSize: 7.5, }, s2: { margin: [5, 0], fontSize: 8, }, bold: { bold: true }, center: { alignment: 'center' } } }; pdfMake.createPdf(docDefinition).open() };