Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

jsPDF Autotable Error #14

Open
omkargudekar opened this issue Apr 16, 2017 · 7 comments
Open

jsPDF Autotable Error #14

omkargudekar opened this issue Apr 16, 2017 · 7 comments

Comments

@omkargudekar
Copy link

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)

@simonbengtsson
Copy link

Have you tried without setting custom fonts?

@smartdev-125
Copy link

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

@smartdev-125
Copy link

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

@smartdev-125
Copy link

Is there any update or news yet?

@ChengYuHin99
Copy link

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

@alkincakiralar1996
Copy link

any solution?

@menty44
Copy link

menty44 commented Feb 1, 2019

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants