jsPDF-CustomFonts-support icon indicating copy to clipboard operation
jsPDF-CustomFonts-support copied to clipboard

jsPDF Autotable Error

Open omkargudekar opened this issue 7 years ago • 7 comments

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)

omkargudekar avatar Apr 16 '17 02:04 omkargudekar

Have you tried without setting custom fonts?

simonbengtsson avatar Sep 12 '17 07:09 simonbengtsson

same here. I tested without setting custom fonts. same error was occurred. Autotable function was working fine without customfont.js.

0xp3p3 avatar Nov 20 '17 04:11 0xp3p3

@simonbengtsson , @sphilee Is there any way to resolve this issue? Your both works are very good. but I can't use your both :(

0xp3p3 avatar Nov 20 '17 07:11 0xp3p3

Is there any update or news yet?

0xp3p3 avatar Nov 26 '17 14:11 0xp3p3

@simonbengtsson
Same issue here too. Please help to fix this issue. Thanks.

mercedesbenz00 avatar Nov 28 '17 08:11 mercedesbenz00

any solution?

alkincakiralar1996 avatar Mar 07 '18 20:03 alkincakiralar1996

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)

menty44 avatar Feb 01 '19 09:02 menty44