简体   繁体   中英

How to open blobURL and print automatically?

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);
                      });
                   };

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM