Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public captureScreen() {
- var data = document.getElementById('contentToConvert');
- html2canvas( data ).then(canvas => {
- var imgWidth =297;
- var pageHeight = 210;
- var imgHeight = canvas.height * imgWidth / canvas.width;
- var heightLeft = imgHeight;
- const contentDataURL = canvas.toDataURL('image/png')
- var doc = new jspdf('l', 'mm', 'a4'); // A4 size page of PDF
- var position = 2;
- doc.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight)
- var pdf =doc.output(); //returns raw body of resulting PDF returned as a string as per the plugin documentation.
- var data = new FormData();
- data.append("data" , pdf);
- var xhr = new XMLHttpRequest();
- xhr.send(data);
- });
- }
- uploadFile(data) {
- const file = data.target.files[0];
- const filePath = Date.now().toString();
- const fileRef = this.storage.ref('/test/' + filePath);
- const task = this.storage.upload('/test/' + filePath, file);
- this.uploadPercent = task.percentageChanges();
- task.snapshotChanges().pipe(
- finalize(() => {
- this.downloadURL = fileRef.getDownloadURL();
- this.downloadURL.subscribe(url => this.url = url
- )
- }))
- .subscribe();
- }
Add Comment
Please, Sign In to add comment