'How to disabled Ctrl+P and Ctrl+S? in ng2-pdfjs-viewer. Right now anyone can print or download using keys.Any suggestion would be appreciated would

I am using ng2-pdfjs-viewer library to display pdf in my angular 7 app. Problem is if print flag is false button to print is not visible that works as expected but user can right click or use CTRL+P or CTRL+S and print or download the pdf. I want to restrict user to use those keys. I tried using JavaScript methods in my dom but those are not working as PDFJS component is overlapping.After all i tried to modify viewer.js file under node_modules folder that worked for me in my machine but we are using Jenkins build tool which use files from SVN and i can not commit node_modules to SVN. Jenkins use libraries from server on the base of package.json so my modification is use less in this case.I tried onBeforePrint event as well that is not invoked don't know why. Please help me on this how we can do that alternatively. Your help will be appreciated.

Thanks.

writing down the code i tried to modify the viewer.js

Code in my component

<mat-dialog-content class="my-2 d-flex justify-content-center px-2">
  <div class="w-100 h-100">
    <ng2-pdfjs-viewer [download]="isPrintable" (onBeforePrint)="beforePrint()" [print]="isPrintable" *ngIf="pdfContent" [pdfSrc]="pdfContent"></ng2-pdfjs-viewer>
</div> 
</mat-dialog-content>

viewer.js modifications

//To disable right click print added by KK on 29/08/2019
window.oncontextmenu = function () {
return false;
}
var hasAttachEvent = !!document.attachEvent;
window.addEventListener('keydown', function (event) {

  //code to prevent download and print using CTRL+S and CTRL+P added by KK on 29/08/2019
  if ((event.keyCode === 80 || event.keyCode === 83) && (event.ctrlKey || event.metaKey) && !event.altKey && (!event.shiftKey || window.chrome || window.opera)) {
    //window.print();

    if (hasAttachEvent) {
      return;
    }

    event.preventDefault();

    if (event.stopImmediatePropagation) {
      event.stopImmediatePropagation();
    } else {
      event.stopPropagation();
    }

    return;
  }

}, false);
 // CTRL + P key combinations you want to disable
  @HostListener('document:keydown', ['$event']) onKeydownHandler(event: KeyboardEvent) {
    if (event.ctrlKey && event.keyCode === 80) {
      return false;
    }
  }


Solution 1:[1]

Worked for me (jQuery used):

$(document).on('keydown', function(e) {
  // on Ctrl+S
  if (e.ctrlKey && e.which == 83) {
    return false
  }
})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Inversion