Kendo UI pdf is opening new window where pop up block is stopping.

1 Answer 325 Views
Drawing API
Babu
Top achievements
Rank 1
Iron
Iron
Iron
Babu asked on 23 Jun 2023, 06:04 PM
I am trying to attach pdf file to email and send email notifications to users. Problem is when try to use kendo.saveAs its opening in another window .  If user browser is having pop up block, the email function is not working as it is not allowing open other window. Is there any way that i can do this in same window or any other option?
$.ajax({
                        type: "POST",
                        data: data,
                        url: "IUA/Submit",
                        success: function (result) {
                            if (result.Id !== 0) {
                                alert("Your application has completed the review phase and is confirmed complete. Your PIN will be " + result.Id + ". To complete your submission, please click the OK button below.");
                                $('#loading').hide();

                                kendo.drawing.drawDOM($("#mainDiv"))
                                    .then(function (group) {
                                        // Render the result as a PDF file
                                        return kendo.drawing.exportPDF(group, {
                                            paperSize: "auto",
                                            margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
                                        });
                                    })
                                    .done(function (data) {
                                        // Save the PDF file
                                        kendo.saveAs({
                                            type: 'POST',
                                            dataURI: data,
                                            fileName: "IUAEnrollment.pdf",
                                            proxyURL: '@Url.Action("SavePDF", "IUA")',
                                            forceProxy: true,
                                            proxyTarget: "_blank"
                                        });
                                        displayLoading("#formDiv", false);
                                        location.reload();
                                    });
                            } else if (result.IsDuplicateRec == true) {
                                $('#loading').hide();
                                $("#divDuplicate").show();
                                $("#captchaDiv").load(location.href + " #captchaDiv>*", "");
                            } else if (result.IsMVCCaptcha == false) {
                                $('label[for="lblCaptchaErr"]').show();
                                $("#captchaDiv").load(location.href + " #captchaDiv>*", "");
                                setTimeout(WaitUntilLoad, 6000);
                            }
                        },
                        error: function () {
                            $('#loading').hide();
                            alert("Error occured during the submission. Please contact helpdesk.");
                        }
                    });

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 28 Jun 2023, 11:40 AM

Hello, Babu,

Could you please try commenting out the highlighted part:

kendo.saveAs({
                                            type: 'POST',
                                            dataURI: data,
                                            fileName: "IUAEnrollment.pdf",
                                            proxyURL: '@Url.Action("SavePDF", "IUA")',
                                            forceProxy: true,
                                            proxyTarget: "_blank"
                                        });

Let me know if that would resolve the problem.

Regards,
Martin
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Babu
Top achievements
Rank 1
Iron
Iron
Iron
commented on 31 Aug 2023, 03:16 PM

not working
Martin
Telerik team
commented on 05 Sep 2023, 11:49 AM

Hello, Babu,

You can see from this Grid Dojo example that setting proxyTarget to blank opens a new tab in the browser, and that commenting that part out changes the behaviour. Kindly provide a small example where we can observe the issue so that we can investigate further.

Tags
Drawing API
Asked by
Babu
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Martin
Telerik team
Share this question
or