jsPDF-CustomFonts-support
jsPDF-CustomFonts-support copied to clipboard
jsPDF Autotable Error
Error when used with Autotable.
Only added autotable and tried to export
<script>
var doc = new jsPDF();
doc.addFont('HMKMMAG.TTF', 'MagicR', 'normal', 'Identity-H');
doc.addFont('HMKMRHD.TTF', 'HeadlineR', 'normal', 'Identity-H');
doc.addFont('msgothic.ttf', 'MsGothic', 'normal', 'Identity-H');
doc.addFont('gothic.ttf', 'LiLing', 'normal', 'Identity-H');
//doc.addFont('HARLOWSI.TTF', 'WMLWQI+HarlowSolid', 'normal', 'WinAnsiEncoding');
//doc.addFont('ITCBLKAD.TTF','a','normal','WinAnsiEncoding');
//doc.addFont('BOD_PSTC.TTF','b','normal','WinAnsiEncoding');
//doc.addFont('GADUGI.TTF', 'GADUGI', 'normal', 'WinAnsiEncoding');
doc.setFont('MagicR'); // set font
doc.setFontSize(20);
doc.setTextColor(153,051,102);
doc.setCharSpace(3);
//doc.setDefaultFonts(0, 'Times'); //English default
//doc.setDefaultFonts(1, 'MagicR'); //Korean default
doc.setDefaultFonts(3, 'LiLing'); //Chinese default
doc.setDefaultFonts(2, 'MsGothic'); //Japanese default
var columns = ["ID", "Name", "Country"];
var rows = [
[1, "Shaw", "홍A平길Bお동安C"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
doc.autoTable(columns, rows,{styles: {font: "MsGothic"}});
doc.save('table.pdf');
</script>
got below error
Uncaught TypeError: Cannot read property 'widths' of undefined at Object.API.getCharWidthsArray (split_text_to_size.js:47:89) at Object.API.getStringUnitWidth (split_text_to_size.js:95:40) jspdf.plugin.autotable.js:311:57 at Array.forEach (native) at Object.getStringWidth (jspdf.plugin.autotable.js:310:10) spdf.plugin.autotable.js:964:71 at Array.forEach (native) jspdf.plugin.autotable.js:962:44 at Array.forEach (native) at Object.calculateWidths (jspdf.plugin.autotable.js:960:19)
Have you tried without setting custom fonts?
same here. I tested without setting custom fonts. same error was occurred. Autotable function was working fine without customfont.js.
@simonbengtsson , @sphilee Is there any way to resolve this issue? Your both works are very good. but I can't use your both :(
Is there any update or news yet?
@simonbengtsson
Same issue here too.
Please help to fix this issue.
Thanks.
any solution?
TypeError: Cannot read property 'API' of undefined
require.js:900 TypeError: Cannot read property 'API' of undefined at Object.
(jspdf.plugin.autotable.js?vslo_v=1549012611128:1806) at webpack_require (jspdf.plugin.autotable.js?vslo_v=1549012611128:41) at Object. (jspdf.plugin.autotable.js?vslo_v=1549012611128:504) at webpack_require (jspdf.plugin.autotable.js?vslo_v=1549012611128:41) at jspdf.plugin.autotable.js?vslo_v=1549012611128:105 at jspdf.plugin.autotable.js?vslo_v=1549012611128:108 at Object.execCb (require.js:1690) at Module.check (require.js:865) at Module. (require.js:1140) at require.js:131 at require.js:1190 at each (require.js:56) at Module.emit (require.js:1189) at Module.check (require.js:940) at Module.enable (require.js:1177) at Module.init (require.js:783)