Commit b197a488 authored by Open Source Developer's avatar Open Source Developer
Browse files

trans

parent 5c805e52
...@@ -13,6 +13,7 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types'; ...@@ -13,6 +13,7 @@ import { ILoginInfo } from '../../store/logininfo/logininfo.types';
import {Router, ActivatedRoute, Params} from '@angular/router'; import {Router, ActivatedRoute, Params} from '@angular/router';
import { BehaviorSubject, Subscription } from 'rxjs/Rx'; import { BehaviorSubject, Subscription } from 'rxjs/Rx';
import * as html2canvas from "html2canvas" import * as html2canvas from "html2canvas"
import * as fs from "fs"
...@@ -31,7 +32,7 @@ import * as html2canvas from "html2canvas" ...@@ -31,7 +32,7 @@ import * as html2canvas from "html2canvas"
[class.evenout]="isEven" (click)="setActiveUser(UserData$.id)" [class.selectedout]="userActive === UserData$.id" > [class.evenout]="isEven" (click)="setActiveUser(UserData$.id)" [class.selectedout]="userActive === UserData$.id" >
<h5> {{UserData$.name}}&nbsp;{{UserData$.studentsurname}} </h5> <h5> {{UserData$.name}}&nbsp;{{UserData$.studentsurname}} </h5>
</li> </li>
<div id = "target"> <div #target class = "target "id = "target">
<div *ngFor="let StudentDetails$ of SubmitedDetails$ | async" [hidden]="UserData$.id !== userActive" > <div *ngFor="let StudentDetails$ of SubmitedDetails$ | async" [hidden]="UserData$.id !== userActive" >
<table> <table>
...@@ -123,6 +124,8 @@ import * as html2canvas from "html2canvas" ...@@ -123,6 +124,8 @@ import * as html2canvas from "html2canvas"
public StudentId; public StudentId;
private userActive = <number>-1; private userActive = <number>-1;
@ViewChild('target') element: ElementRef;
constructor(private _hds: HelperDataService, constructor(private _hds: HelperDataService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router , private router: Router ,
...@@ -211,39 +214,65 @@ import * as html2canvas from "html2canvas" ...@@ -211,39 +214,65 @@ import * as html2canvas from "html2canvas"
} }
createPdf1() createPdf()
{ {
html2canvas(document.getElementById("target")).then(function(canvas) html2canvas(document.getElementById("target")).then(function(canvas)
{ {
var img = canvas.toDataURL(); console.log("i am !");
var doc = new jsPDF();
doc.onload = function(){ if(document.readyState === "complete") {
console.log(img, doc, "lalalalalala"); console.log("mphka");
doc.addImage(img, 'PNG',0, 0, 210, 297); var img = canvas.toDataURL();
doc.save('applications.pdf'); var fs = require('fs');
} var sys = require('sys');
});
}
var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0"
+ "NAAAAKElEQVQ4jWNgYGD4Twzu6FhFFGYYNXDUwGFpIAk2E4dHDRw1cDgaCAASFOffhEIO"
+ "3gAAAABJRU5ErkJggg==";
var data = img.replace(/^data:image\/\w+;base64,/, "");
var buf = new Buffer(data, 'base64');
fs.writeFile('image.png', buf);
createPdf()
var doc = new jsPDF();
console.log("mphkaneo");
doc.addImage(img, 'PNG',0, 0, 1000, 1000);
console.log("mphkaneoneo");
doc.save('applications.pdf');
}
});
}
{
var doc = new jsPDF();
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');
// Save the PDF
doc.save('Test.pdf'); createPdf1()
} {
html2canvas(document.getElementById("target"), <Html2Canvas.Html2CanvasOptions>{
onrendered: function(canvas: HTMLCanvasElement) {
console.log("lalalal");
var img = canvas.toDataURL();
var doc = new jsPDF();
doc.addImage(img, 'PNG',0, 0, 210, 297);
doc.save('applications.pdf');
},
function(error){
console.log("i fail");
}
});
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment