Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
b197a488
Commit
b197a488
authored
May 16, 2017
by
Open Source Developer
Browse files
trans
parent
5c805e52
Changes
1
Hide whitespace changes
Inline
Side-by-side
source/components/student-application-form/submited.aplication.preview.ts
View file @
b197a488
...
@@ -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}} {{UserData$.studentsurname}} </h5>
<h5> {{UserData$.name}} {{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"
}
}
createPdf
1
()
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
,
"
lalalalalal
a
"
);
console
.
log
(
"
mphk
a
"
);
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
"
);
}
});
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment