forked from sphilee/jsPDF-CustomFonts-support
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
43 lines (34 loc) · 1.66 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>jsPDF customfonts example</title>
<script language="javascript" type="text/javascript" src="./dist/jspdf.customfonts.min.js"></script>
<script language="javascript" type="text/javascript" src="./dist/default_vfs.js"></script>
</head>
<body>
<script>
var doc = new jsPDF();
doc.addFont('Batang.ttf', 'Batang', 'normal');
doc.addFont('NotoSansCJKjp-Regular.ttf', 'NotoSansCJKjp', 'normal');
doc.addFont('NotoSansCJKtc-Regular.ttf', 'NotoSansCJKtc', 'normal');
doc.setFont('Batang');
doc.text(15, 15, '안녕하세요 만나서 반갑습니다.');
doc.setFont('NotoSansCJKjp');
doc.text(15, 30, 'こんにちは。はじめまして。');
doc.setFont('NotoSansCJKtc');
doc.text(15, 45, '早上好。 很高兴见到你');
//multi-lines Test
var paragraph = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit,' +
' sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' +
' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' +
' nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor ' +
'in reprehenderit in voluptate velit esse cillum dolore eu fugiat ' +
'nulla pariatur. Excepteur sint occaecat cupidatat non proident, ' +
'sunt in culpa qui officia deserunt mollit anim id est laborum.';
var lines = doc.splitTextToSize(paragraph, 150);
doc.text(15, 60, lines);
doc.save('custom_fonts.pdf');
</script>
</body>
</html>