Home > database >  How to open blobURL and print automatically?
How to open blobURL and print automatically?

Time:06-21

I have the codes to open the blobURL in a new window but I want it to open the print window automatically without having to click on the print button. Please advise. The current code is now printing the old window which is not what I want to print. Id want to print the new window which is the pdf file.

                    var pdfExpComplete = (args) => {
                        args.promise.then((e) => {
                            var blobURL = URL.createObjectURL(e.blobData);
                            window.open(blobURL);
                            window.print(blobURL);
                    });

                   $scope.pdfExpComplete = function (args) {
                      args.promise.then(function (e) {
                      var blobURL = URL.createObjectURL(e.blobData);
                      window.open(blobURL);
                      });
                   };

CodePudding user response:

Got the answer. I can just add print() after opening the new window.

var pdfExpComplete = (args) => {
args.promise.then((e) => {
    var blobURL = URL.createObjectURL(e.blobData);
    window.open(blobURL).print();
});

CodePudding user response:

We can open the bloburl and print the document automatically by using the below code snippet, please try the below code and let us know the result.

var blobURL = URL.createObjectURL(e.blobData);
window.open(blobURL).print();

https://www.syncfusion.com/kb/11941/how-to-open-a-pdf-in-a-new-tab-or-download-a-pdf-document-using-ajax-call

Note: I work for Syncfusion.

Regards,

Gowthamraj K

  • Related