This is a migrated thread and some comments may be shown as answers.

saveAs callback

7 Answers 234 Views
Drawing API
This is a migrated thread and some comments may be shown as answers.
Nisarg
Top achievements
Rank 1
Nisarg asked on 06 Feb 2017, 04:37 PM

Hi there,

I am using this method 'kendo.drawing.pdf.saveAs' to export pdf. Is there a callback or a promise in this method. Or is there a way to know when the download is accepted or canceled by the user?

Thanks in advance!

7 Answers, 1 is accepted

Sort by
0
Eduardo Serra
Telerik team
answered on 06 Feb 2017, 04:54 PM
Hello Nisarg,

We can use the method you describe as follows:

drawing.pdf.saveAs(group, "filename.pdf", proxyUrl, callback);

where the proxyUrl and callback arguments are optional; the callback will be invoked when the file has been successfully generated (generation could be asynchronous).

I hope this helps!

Regards,
Eduardo Serra
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Nisarg
Top achievements
Rank 1
answered on 06 Feb 2017, 09:50 PM

[quote]the callback will be invoked when the file has been successfully generated (generation could be asynchronous).[/quote]

So you mean that I cannot be sure if the user has closed the download prompt?

The reason that I need this callback is because I am exporting the pdf from a new tab, and when the download is done, I want to close the tab automatically.

Will the callback satisfy this functionality?

0
Accepted
Eduardo Serra
Telerik team
answered on 07 Feb 2017, 06:27 PM
Hello Nisarg,

Although every application is different, I think from what you describe that the callback will satisfy your needs and allow you to know when to close the tab.

If you find trouble during the implementation of this feature, reply back in a new forum thread and we will help you.

Thank you.

Regards,
Eduardo Serra
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Cameron
Top achievements
Rank 1
answered on 18 Jun 2019, 12:38 AM
Does not appear to work in the JQuery interface???
0
Alex Hajigeorgieva
Telerik team
answered on 19 Jun 2019, 03:56 PM
Hi, Cameron,

It seem to work in my test Dojo I created:

https://dojo.telerik.com/@bubblemaster/eNUquyIl

Please inspect it and let me know in case I have missed anything.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Cameron
Top achievements
Rank 1
answered on 20 Jun 2019, 12:47 AM
I was trying to do this type of thing.
It generates a pdf but could not get the callback.

function exportToPdf_WritingCriteria() {
$(".highcharts-root").remove();
kendo.drawing.drawDOM($(".reportDisplay_WritingCriteria"), {
paperSize: ["230mm", "280mm"],
scale: 0.5,
margin: {
left: "1cm",
top: "2cm",
right: "1cm",
bottom: "0.5cm"
},
template: $("#page-template_WritingCriteria").html(),
avoidLinks: true,
repeatHeaders: true
})
.then(function (group) {
// Render the result as a PDF file
return kendo.drawing.exportPDF(group, {
paperSize: "A4",
landscape: false
});
})
.done(function (data) {
$("#exportbtn_WritingCriteria").prop('disabled', false);
$("#chartArea_WritingCriteria").show();
$("#exportPdfRunningSpan_WritingCriteria").hide();
// Save the PDF file
kendo.saveAs({
dataURI: data,
fileName: "WritingCriteria.pdf",
proxyURL: "/Home/PdfExportSave",
forceProxy: true
});
// Tried a few variations of this but did not run.
//drawing.pdf.saveAs(data, "WritingCriteria.pdf", "/Home/PdfExportSave", function () {
// alert("Drawing is complete")
//});
});
0
Alex Hajigeorgieva
Telerik team
answered on 21 Jun 2019, 03:00 PM
Hi, Cameron,

Thank you very much for sharing your code. Now I understand why the issue occurs.

The current code uses the kendo.saveAs() method which does not have a callback while this thread is focused on the kendo.drawing.pdf.saveAs() method. To implement it in your code, you should replace the logic where the DOM is exported to PDF because the drawing method works with drawing groups, not dataURIs:

https://dojo.telerik.com/@bubblemaster/EJIDIQUx

Naturally, you may use the callback to execute the extra logic which shows/hides elements etc.

Let me know if you have further questions or concerns.

Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Drawing API
Asked by
Nisarg
Top achievements
Rank 1
Answers by
Eduardo Serra
Telerik team
Nisarg
Top achievements
Rank 1
Cameron
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or