出现错误,无法打开PDF文件进行打印

时间:2019-02-01 10:32:33

标签: javascript jquery html

当前,我正在尝试打开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-8dataType: "text"dataType: "html",并且也使用了

xhrFields: {
  responseType : 'blob'
},

但仍然无法正常工作。

enter image description here

0 个答案:

没有答案