首页 > 解决方案 > PDF 文件未打开打印给定错误

问题描述

目前,我正在尝试打开 PDF 文件进行打印,但出现错误File is not PDF document

我使用了以下 JS 脚本:

$.ajax({
  type: "POST",
  url: ajaxURL,         
  data: { order_id: idsss,shipment:1, shipping_method : oshipping_method,delivery_method:favorite},
  /*contentType: "application/json; charset=utf-8"*/
}).done(function(data) {
  var obj = jQuery.parseJSON(data);         
  console.log(obj);     
  $('#myaccount').prepend(obj.scriptname);
  if(obj.filenames != "")
  {
    var splitFiles = obj.filenames.split(',');
    $.each(splitFiles, function( index, value ) {javascript:jsWebClientPrint.print('useDefaultPrinter=undefined&printerName=null&filetype=PDF&name='+value);
    });
  }
}); 

我也尝试添加内容类型application/json; charset=utf-8, dataType: "text",dataType: "html"并且还使用了

xhrFields: {
  responseType : 'blob'
},

但还是不行。

在此处输入图像描述

标签: javascriptjqueryhtml

解决方案


推荐阅读