123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- var fonts = {
- Roboto: {
- normal: 'fonts/Roboto-Regular.ttf',
- bold: 'fonts/Roboto-Medium.ttf',
- italics: 'fonts/Roboto-Italic.ttf',
- bolditalics: 'fonts/Roboto-.ttf',
- }
- };
-
- var pdfMake = require('pdfmake/build/pdfmake.js');
- var pdfFonts = require('pdfmake/build/vfs_fonts.js');
- pdfMake.vfs = pdfFonts.pdfMake.vfs;
-
- function table(course) {
- return {
- widths: [100, 300],
- headerRows: 2,
- body: [
- [{text: `${course.code} ${course.title}`, bold: true, colSpan: 2, alignment: 'center'}, {}],
- ['Seccion', 'Profesor'],
- ].concat( course.sections.map( function(section) {
- if (section.hasOwnProperty('professors')) {
- return [section.code, section.professors.map( function (professor) {
- return professor.first_name + ' ' + professor.last_name;
- })];
- } else {
- return [section.code, ''];
- }
- }))
- }
- }
- var docDef = {
- content: [
- {text: `Horario BIOL ${data.alpha}`, style: 'header'},
- {text: 'sujeto a cambios', style: 'header', fontSize: 18},
- ].concat( data.courses.map( function(course) {
- return {
- style: 'tableStyle',
- alignment: 'center',
- table: table(course)
- }
- })),
- styles: {
- header: {
- fontSize: 22,
- bold: true,
- alignment: 'center',
- },
- tableStyle: {
- margin: [50,10,0,15]
- },
- }
-
- };
-
- pdfMake.createPdf(docDef).download();
- window.location.replace("/dashboard");
|