【问题标题】:requirejs, datatables and pdfmake - Uncaught File 'Roboto-Regular.ttf' not found in virtual file systemrequirejs、datatables 和 pdfmake - 在虚拟文件系统中找不到未捕获的文件“Roboto-Regular.ttf”
【发布时间】:2018-02-23 17:57:10
【问题描述】:

这是我的代码。

requirejs.config({
 "paths":{
'pdfmake': '//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min',
},

"shim": {
'pdfmake': {
            deps: ["//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"]
        },
}

});

在数据表中 - https://datatables.net/extensions/buttons/examples/html5/pdfMessage.html

requirejs(['pdfmake'],function(){
 $('#example').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'pdfHtml5',
                messageTop: 'PDF created by PDFMake with Buttons for DataTables.'
            }
        ]
    } );

});

在检查中我看到文件已加载,但是当我创建 pdf 时 - 获取

Uncaught File 'Roboto-Regular.ttf' not found in virtual file system

更新 1 我尝试创建实时示例但有一些错误... https://jsfiddle.net/9gkat5dc/13/

无法将“https://cdn.datatables.net/buttons/1.4.2/swf/flashExport.swf”作为插件加载,因为加载插件的框架是沙盒。

【问题讨论】:

    标签: datatables requirejs pdfmake


    【解决方案1】:
    "shim": {
        "vfs_fonts": ["pdfmake"]
    },
    

    应该解决这个问题(它在我的安装中)。 vfs_fonts 需要在 pdfmake 之后加载,而不是之前。据我了解您的配置,您的 pdfmake 取决于 vfs_fonts。

    编辑:我看到您将 URL 添加到 vfs_fonts 作为 dep。我在路径数组中做了这个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-02
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-04
      相关资源
      最近更新 更多