【问题标题】:Error importing autotable plugin for Js PDF为 Js PDF 导入自动表格插件时出错
【发布时间】:2017-10-31 16:34:42
【问题描述】:

我只是在尝试将此插件导入我的项目时遇到了痛苦。

我从他们的 GitHub 获得链接 https://github.com/simonbengtsson/jsPDF-AutoTable

我将脚本添加到 HTML 头部,但它不起作用。

 <script src="https://github.com/simonbengtsson/jsPDF-AutoTable"></script>

我使用 js pdf 没有导入任何东西,它正在工作,但我不能使用插件

function(){

      var pdf = new jsPDF();
      //This lane is not working
      //pdf.autoTable(headerTABLE, myTableArray);
      //
      pdf.addPage();
      var dataURLLogo = canvasLogo.toDataURL("image/jpeg;base64");
      var dataURLLogoSEFAC = canvasLogoSEFAC.toDataURL("image/jpeg;base64");
      var dataURLGrafica = canvas.toDataURL("image/jpeg;base64");

      pdf.setFontSize(25);
      pdf.setTextColor(159, 233, 96);
      pdf.setFontType('bold');
      pdf.addImage(dataURLLogo, 'jpeg', 35,25,20,20);  

错误:pdf.autoTable 不是函数

对不起我的英语。请帮忙!

【问题讨论】:

  • 不能直接从github加载文件。尝试从源代码树加载库。
  • 试过 但不工作。
  • 顺便说一句,我添加了
  • 插件的自述文件中解释了如何开始使用插件。你试过吗?

标签: javascript html jspdf jspdf-autotable


【解决方案1】:

终于找到答案了:

只需在 m html 头中的所有其他脚本之前添加这两个脚本。

    <script src="https://cdn.rawgit.com/simonbengtsson/jsPDF/requirejs-fix-dist/dist/jspdf.debug.js"></script>
    <script src="https://unpkg.com/jspdf-autotable@2.3.2"></script>

感谢所有试图帮助回答我的问题的人!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 1970-01-01
    • 2016-12-09
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    相关资源
    最近更新 更多