Facny box print callbacks

吃可爱长大的小学妹 提交于 2019-12-25 05:45:12

问题


I am working with fancybox2 and I need to add some custom functions before pdf goes to print queue means I need fancybox print callbacks(like before print,after print), Can anyone please help me ? I tried window.print() callbacks but those are not working in case of fancybox print , following are the sample I used

$(function(){
  var beforePrint = function() {
    alert("BEfore print")
    console.log('Functionality to run before printing.');
  };
  var afterPrint = function() {
    console.log('Functionality to run after printing');
    alert("After print")
  };

  if (window.matchMedia) {
    var mediaQueryList = window.matchMedia('print');
    console.log("Match media ..." + mediaQueryList)
    mediaQueryList.addListener(function(mql) {
      console.log("Mql matches ...."+ mql.matches)
      if (mql.matches) {
        beforePrint();
      } else {
        afterPrint();
      }
    });
  }

  window.onbeforeprint = beforePrint;
  window.onafterprint = afterPrint;
}());

This is not working for fancybox prints but working when we try window prints(like when we use ctrl + p). I need to handle print call backs when we click on fancybox pdf print icon , please look at the attached image

The following is the firefox screenshot , see how firefox renders fancy box pdf different from crhome browser, firefox uses pdf viewer.

After I spent some time over google ,I found fancybox embed pdf renders differently in different browsers(see above attached images), firefox uses pdf viewer and chrome uses Adobe's viewer etc., There must be something that we can control all pdf printing trhough javascript

来源:https://stackoverflow.com/questions/32063339/facny-box-print-callbacks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!