Facny box print callbacks
Asked Answered
I

0

0

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 enter image description here

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

enter image description here

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

Inulin answered 18/8, 2015 at 4:2 Comment(3)
Check https://mcmap.net/q/1174044/-fancybox-add-print-function-closed ... I guess you could add your callbacks in the .on("click", "#fancy_print") methodSlipway
@Slipway by using the above link it raises browser window prints , I strongly feel it must be dealt with pdf print callbacks using jquery since each browser having its own mechanism to render pdf on browser as I mentioned at the bottom of my questionInulin
@Slipway please check question I updated itInulin

© 2022 - 2024 — McMap. All rights reserved.