1+ <!DOCTYPE html>
2+ < html >
3+
4+ < head >
5+ < meta http-equiv ="Content-type " content ="text/html; charset=utf-8 " />
6+ < title > jsPDF custom fonts example</ title >
7+ < script language ="javascript " type ="text/javascript " src ="../../jspdf.js "> </ script >
8+ < script language ="javascript " type ="text/javascript " src ="../../node_modules/filesaver.js/FileSaver.js "> </ script >
9+ < script language ="javascript " type ="text/javascript " src ="../../plugins/split_text_to_size.js "> </ script >
10+ < script language ="javascript " type ="text/javascript " src ="../../plugins/standard_fonts_metrics.js "> </ script >
11+ < script language ="javascript " type ="text/javascript " src ="../../plugins/customfonts.js "> </ script >
12+ < script language ="javascript " type ="text/javascript " src ="./vfs_fonts.js "> </ script >
13+ </ head >
14+
15+ < body >
16+ < script >
17+ var doc = new jsPDF ( ) ;
18+
19+ doc . addFont ( 'HMKMMAG.TTF' , 'MagicR' , 'normal' , 'Identity-H' ) ;
20+ doc . addFont ( 'msgothic.ttf' , 'MsGothic' , 'normal' , 'Identity-H' ) ;
21+ doc . addFont ( 'gothic.ttf' , 'LiLing' , 'normal' , 'Identity-H' ) ;
22+ //doc.addFont('HARLOWSI.TTF', 'WMLWQI+HarlowSolid', 'normal', 'WinAnsiEncoding');
23+ //doc.addFont('ITCBLKAD.TTF','a','normal','WinAnsiEncoding');
24+ //doc.addFont('BOD_PSTC.TTF','b','normal','WinAnsiEncoding');
25+ //doc.addFont('GADUGI.TTF', 'GADUGI', 'normal', 'WinAnsiEncoding');
26+
27+
28+
29+ doc . setFont ( 'MagicR' ) ; // set font
30+ doc . setFontSize ( 30 ) ;
31+ doc . setTextColor ( 153 , 051 , 102 ) ;
32+ doc . setCharSpace ( 3 ) ;
33+
34+ //doc.setDefaultFonts(0, 'Times'); //English default
35+ //doc.setDefaultFonts(1, 'MagicR'); //Korean default
36+ // doc.setDefaultFonts(3, 'LiLing'); //Chinese default
37+ // doc.setDefaultFonts(2, 'MsGothic'); //Japanese default
38+
39+
40+
41+
42+ doc . drawText ( 10 , 20 , [ '안녕하세요 저는 jsPDF의 custom font 개발자 이관형입니다.' , {
43+ text : '你好,很高兴见到你 你叫什么名字?' ,
44+ fontSize : 30 ,
45+ textColor : [ 255 , 0 , 0 ] ,
46+ charSpace : 3 ,
47+ font : 'LiLing'
48+ } , {
49+ text : 'こんにちは。あなたの名前は何ですか?' ,
50+ fontSize : 20 ,
51+ textColor : [ 0 , 150 , 0 ] ,
52+ charSpace : 3 ,
53+ font : 'MsGothic'
54+ } ] ) ;
55+
56+ doc . save ( 'custom_fonts.pdf' ) ;
57+ </ script >
58+ </ body >
59+
60+ </ html >
0 commit comments