Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- createPdf(){
- var docDefinition = {
- content: [
- { text: 'REMINDER', style: 'header'},
- { text: new Date().toTimeString(), aligmente: 'right'},
- { text: 'From', style: 'subheader'},
- {text: this.letterObj.from},
- {text: 'To', style: 'subheader'},
- this.letterObj.to,
- {text: this.letterObj.text, style: 'story', margin: [0, 20, 0, 20]},
- {
- ul: [
- 'Bacon',
- 'Rips',
- 'BBQ',
- ]
- }
- ],
- styles: {
- header: {
- fontSize: 14,
- bold: true,
- margin: [0, 15, 0, 0]
- },
- Story: {
- italic: true,
- alignment: 'center',
- width: '50%',
- }
- }
- }
- this.pdfObj = pdfMake.createPdf(docDefinition);
- }
- downloadPdf(){
- if(this.platform.is('cordova')){
- this.pdfObj.getBuffer((buffer) =>{
- var utf8 = new Uint8Array(buffer);
- var binaryArray = utf8.buffer;
- var blob = new Blob([binaryArray], { type: 'application/pdf'});
- this.file.writeFile(this.file.dataDirectory, 'myletter.pdf', blob, { replace: true}).then(fileEntry =>{
- this.fileOpener.open(this.file.dataDirectory + 'myletter.pdf', 'application/pdf');
- })
- })
- }else {
- this.pdfObj.download()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement