const fs = require('fs'); const PDFDocument = require('./pdfkit-tables'); const doc = new PDFDocument(); doc.pipe(fs.createWriteStream('comprobante.pdf')); // Embed a font, set the font size, and render some text // Add an image, constrain it to a given size, and center it vertically and horizontally const table0 = { headers: ['Word', 'Comment', 'Summary'], rows: [ ['Apple', 'Not this one', 'la gravida ultrices. Fusce vitae pulvinar magna.'], ['Tire', 'Smells like funny', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla viverra at ligula gravida ultrices. Fusce vitae pulvinar magna.'] ] }; doc.table(table0, { prepareHeader: () => doc.font('Helvetica-Bold'), prepareRow: (row, i) => doc.font('Helvetica').fontSize(12) }); const table1 = { headers: ['Country', 'Conversion rate', 'Trend'], rows: [ ['Switzerland', '12%', '+1.12%'], ['France', '67%', '-0.98%'], ['England', '33%', '+4.44%'] ] }; doc.moveDown().table(table1, 100, 350, { width: 300 }); doc.end(); // let inicio = 120; // doc.image('Imagenes/logo_unam.png', inicio, 30, { scale: 0.04 }); // doc.font('Times-Roman') // .fontSize(10) // .text('UNIVERSIDAD NACIONAL AUTONOMA DE MEXICO', inicio + 60, 40); // doc.font('Times-Roman') // .fontSize(10) // .text('FACULTAD DE ESTUDIOS SUPERIORES ACATLÁN', inicio + 66, 50); // doc.font('Times-Roman') // .fontSize(10) // .text('JORNADA DE INSERCIÓN LABORAL', inicio + 95, 60); // doc.image('Imagenes/Fesa.jpg', inicio + 305, 30, { scale: 0.05 }); // // Add another page // doc.font('Times-Roman') // .fontSize(8) // .text('COMPROBANTE DE INSCRIPCIÓN', inicio + 120, 80); // let marg = 70; // doc.image('Imagenes/qr_ejemplo.png', marg, 120, { scale: 0.50 }); // // doc.moveTo(marg + 100, 120) // // .lineTo(marg + 200, 120) // // .stroke(); // doc.addPage() // .fontSize(25) // .text('Here is some vector graphics...', 100, 100); // // Draw a triangle // doc.save() // .moveTo(100, 110) // .lineTo(100, 110) // .lineTo(100, 150) // .fill("#FF3300"); // // Apply some transforms and render an SVG path with the 'even-odd' fill rule // doc.scale(0.6) // .translate(470, -380) // .path('M 250,75 L 323,301 131,161 369,161 177,301 z') // .fill('red', 'even-odd') // .restore(); // // Add some text with annotations // // doc.addPage() // // .fillColor("blue") // // .text('Here is a link!', 100, 100) // // .underline(100, 100, 160, 27, { color: "#0000FF" }) // // .link(100, 100, 160, 27, 'http://google.com/'); // // Finalize PDF file // doc.end(); // const PDFDocument = require('pdfkit'); // var fs = require('fs'); // // Create a document // const doc = new PDFDocument; // // Pipe its output somewhere, like to a file or HTTP response // // See below for browser usage // doc.pipe(fs.createWriteStream('output.pdf')); // // Embed a font, set the font size, and render some text // doc.font('fonts/PalatinoBold.ttf') // .fontSize(25) // .text('Some text with an embedded font!', 100, 100); // // Add an image, constrain it to a given size, and center it vertically and horizontally // doc.image('path/to/image.png', { // fit: [250, 300], // align: 'center', // valign: 'center' // }); // // Add another page // doc.addPage() // .fontSize(25) // .text('Here is some vector graphics...', 100, 100); // // Draw a triangle // doc.save() // .moveTo(100, 150) // .lineTo(100, 250) // .lineTo(200, 250) // .fill("#FF3300"); // // Apply some transforms and render an SVG path with the 'even-odd' fill rule // doc.scale(0.6) // .translate(470, -380) // .path('M 250,75 L 323,301 131,161 369,161 177,301 z') // .fill('red', 'even-odd') // .restore(); // // Add some text with annotations // doc.addPage() // .fillColor("blue") // .text('Here is a link!', 100, 100) // .underline(100, 100, 160, 27, { color: "#0000FF" }) // .link(100, 100, 160, 27, 'http://google.com/'); // // Finalize PDF file // doc.end