pdfkit/examples/text-link.js
Luiz Américo Pereira Câmara 5fbdfd6383 Reorganize and cleanup examples
2021-07-10 23:20:27 -03:00

27 lines
728 B
JavaScript

var fs = require('fs');
var PDFDocument = require('../');
var doc = new PDFDocument({ bufferPages: true });
doc.pipe(fs.createWriteStream('text-link.pdf'));
doc.addPage();
doc.addPage();
doc.switchToPage(0);
doc.text('First Page', { paragraphGap: 4 });
doc.text('Click here to go to Second Page', { link: 1, paragraphGap: 4 });
doc
.text('Continued text ', { continued: true })
.text('with a link inside', {
continued: true,
link: 'http://pdfkit.org',
underline: true
})
.text(' and remaining text', {
continued: false,
link: null,
underline: false
});
doc.switchToPage(1);
doc.text('Go To First Page', { link: 0 });
doc.text('Link to google', { link: 'https://www.google.com/' });
doc.end();