Skip to content

Instantly share code, notes, and snippets.

@fabriciocarraro
Created March 21, 2023 21:22
Show Gist options
  • Save fabriciocarraro/7c3dc9cc871b8d89b5f87e10b9eda206 to your computer and use it in GitHub Desktop.
Save fabriciocarraro/7c3dc9cc871b8d89b5f87e10b9eda206 to your computer and use it in GitHub Desktop.
var fonts = {
Roboto: {
normal: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.1/fonts/Roboto/Roboto-Regular.ttf',
bold: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.1/fonts/Roboto/Roboto-Medium.ttf',
italics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.1/fonts/Roboto/Roboto-Italic.ttf',
bolditalics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.3.0-beta.1/fonts/Roboto/Roboto-MediumItalic.ttf'
}
};
var pdfmake = require('pdfmake');
pdfmake.addFonts(fonts);
// playground requires you to assign document definition to a variable called dd
var docDefinition = {
content: [
{text: 'Tables', style: 'header'},
{text: '1.'},
//{image: 'logo.png'},
{
style: 'tableExample',
table: {
body: [
['Ben'],
['Sen ve ben.'],
[{
border: [false, false, false, false],
text: '',
}],
['I'],
['You and I.'],
['You and I.'],
['Turkish is an agglutinative language, which means that suffixes are attached to word roots or stems, one following the other in a sequence, to arrange words.\n\nTo conjugate a verb in the Present Continuous tense, we add a tense suffix and a person suffix to the verb stem.\nverb stem + (i)yor + person suffix.\n\nTurkish is also a harmonic language, which means the initial consonant in some suffixes and the vowels in almost all suffixes depend on the consonants or vowels that precede them. \nIf the verb stem ends in a, e, o, ö; these vowels are dropped and \"-(i)yor\" changes to harmonize with the preceding vowel. This is because in Turkish there is something called vowel harmony. We will talk more about it later.\n\nEvery verb in Turkish in the infinitive form ends in either \"-mak\" or \"-mek\", and to find the stem of a verb, you can simply drop this ending. \nIn our example İste- is the stem of the verb istemek (to want).\nThe personal suffix for first person singular is \"-um\".\n\nİste + (i)yor + um => İstiyorum.\nNotice that we dropped the letter “e”.\n\nUnless specifically emphasizing the person, personal pronouns (like ben and sen) are almost always omitted, since the personal suffix already suggests who or what the subject of the sentence.\n\n(Ben) istiyorum.'],
]
}
},
],
styles: {
header: {
fontSize: 18,
bold: true,
margin: [0, 0, 0, 10]
},
subheader: {
fontSize: 16,
bold: true,
margin: [0, 10, 0, 5]
},
tableExample: {
margin: [0, 5, 0, 15]
},
tableHeader: {
bold: true,
fontSize: 13,
color: 'black'
}
},
defaultStyle: {
// alignment: 'justify'
}
};
var pdf = pdfmake.createPdf(docDefinition);
pdf.write('pdfs/document.pdf').then(() => {
// success event
}, err => {
// error event
console.error(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment