pdf导出 预览、直接打印、打印加预览

前台:

 var xueurl = "fileFormatController.do?getXbDetail_print&id=&codes=" + rowsData[0].arrivalLabelcode;
 $.messager.defaults = { ok: "确定", cancel: "取消" };
 const html = '<p id="p"><label for="r">请选择打印方式</label></p><p id="p">'
         + '      <label for="r"><input type="radio" id="r" name="impTypess" value="1" checked>'
         + ' 直接打印</label>'
         + '      <label for="r1"><input type="radio" id="r1" name="impTypess" value="2">'
         + ' 预览</label></p>  </p>'
         + '      <label for="r2"><input type="radio" id="r2" name="impTypess" value="3" >'
         + ' 打印并预览</label></p>  </p>'
  $.messager.confirm("请选择打印方式", html, function (data) {
   if (data) {
        var impTypess = $("input[name='impTypess']:checked ").val();
        xueurl+='&impTypess='+impTypess;
        if(impTypess=='2'){//预览
            window.open(xueurl);
        }else if(impTypess=='3'){//预览并打印
            window.open(xueurl);
            window.location.href = 'fileFormatController.do?getXbDetail_print&id=&codes=" + rowsData[0].arrivalLabelcode'+'&impTypess=1';
        }else if(impTypess=='1'){//打印
            window.location.href = 'fileFormatController.do?getXbDetail_print&id=&codes=" + rowsData[0].arrivalLabelcode'+'&impTypess=1';
        }
    }
 });

  

后台:

通过判断 选择加或者不加实现 预览不预览

response.setHeader("Expires", "0");
			response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
			response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("收货清单.pdf" , "UTF-8"));
			response.setHeader("Pragma", "public");
			response.setContentType("application/pdf");

  

posted @ 2022-06-21 10:27  薛柏梁  阅读(413)  评论(0编辑  收藏  举报