0

我很难显示传递 pdf 文件的打印模式。

    setTimeout(() => {            
        printJS({
        printable: '53544.pdf',
        type: 'pdf',
        showModal: true,    
        fallbackPrintable: () => console.log("FallbackPrintable"),      
        onPrintDialogClose: () => console.log('The print dialog was closed'),
        onIncompatibleBrowser: () => console.log('Pdf was opened in a new tab due to an incompatible browser')
        })
        console.log("TimeOut Executado");
        }
        ,3000)

它只是与pdf 文件有关,我用类似的图像进行了测试logo.png并且它有效。我插入该参数以回调以试图找出正在发生的事情并被OnPrintDialogClose()触发,但模态框没有显示!屏幕闪烁并显示此消息'The print dialog was closed'

有什么建议吗?

4

1 回答 1

0

查看https://printjs.crabbly.com/#configuration我发现还有一些配置选项可能会给您提供线索。我建议尝试这个(我添加了 onError 和 modalMessage):

setTimeout(() => {            
  printJS({
    printable: '53544.pdf',
    type: 'pdf',
    showModal: true, 
    modalMessage: "Document Loading...",
    onError: (err) => console.log(err),
    fallbackPrintable: () => console.log("FallbackPrintable"),      
    onPrintDialogClose: () => console.log('The print dialog was closed')
  });
  console.log("TimeOut Executado");
  }, 3000)

那么我的故障排除问题将是:

  • 如果您查看该页面的 url,将 /53544.pdf 附加到正确的位置?
  • 如果您查看开发人员工具的网络选项卡,您是否看到请求的 pdf 并且它是否成功?
于 2020-11-29T04:19:09.357 回答