Created
July 14, 2021 02:11
-
-
Save programmeruser2/4ac2642f01185b4724c1668add57d7ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iframe = document.getElementById('iframe'); //OR WHATEVER | |
// create a document and pipe to a blob | |
var doc = new PDFDocument(); | |
var stream = doc.pipe(blobStream()); | |
const data = 'YOUR DATA WITH TERM/MEANING SEPERATED BY TAB (\t) AND CARDS SEPERATED WITH A NEWLINE'; | |
//console.log(data); | |
const cards = data.split('\n'); | |
const allPages = []; | |
cards.forEach(card => { | |
const [a,b] = card.split('\t'); | |
allPages.push(a); | |
allPages.push(b); | |
}) | |
allPages.forEach(item => { | |
doc.text(item); | |
doc.addPage(); | |
}) | |
doc.end(); | |
stream.on('finish', function() { | |
iframe.src = stream.toBlobURL('application/pdf'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment