PDF Template headers are removed when using exportPDF

1 Answer 33 Views
Template
Jerry
Top achievements
Rank 1
Iron
Iron
Iron
Jerry asked on 24 Oct 2024, 08:49 PM

Using the example from this page: https://docs.telerik.com/kendo-ui/framework/pdf/page-templates

My goal is to produce a PDF from the webpage with a header and footer as shown on the page above, and to be able to save the PDF to a location.

When using this method, the template header and footer display correctly.

 kendo.drawing.drawDOM("#grid", {
                  paperSize: "A4",
                  margin: "3cm",
                  template: $("#page-template").html()     //WORKS
              }).then(function(group){
                  kendo.drawing.pdf.saveAs(group, "filename.pdf");
              });

However, when using this method, the "template" is ignored. I have tried placing the properties in the "saveAs" object, but this didn't work either.

kendo.drawing.drawDOM("#grid", {
              }).then(function(group){
		return kendo.drawing.exportPDF(group, {
                        paperSize: "A4",
                        margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" },
                        template: $("#page-template").html()   //IGNORED
                    });
              })
                .done(function (data) {
                    kendo.saveAs({
                        dataURI: data,
                        fileName: "filename.pdf",
                        //proxyURL: "myurl/Test/"
                    });
                });

How can I get the template to show the header and footers with the 2nd method?

Or does the "kendo.drawing.pdf.saveAs" have a "proxyURL" property?

 

 

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 29 Oct 2024, 12:01 PM

Hi Jerry,

Generally, the "kendo.drawing.pdf.saveAs" internally invokes the "kendo.saveAs" method. This method calls the "postToProxy" function. Thus, the following is also valid:

 kendo.drawing.drawDOM("#grid", {
        paperSize: "A4",
        template: $("#page-template").html()
      }).then(function(group) {
        return kendo.drawing.exportPDF(group);
      }).done(function (data) {
	// Save the PDF file
	kendo.saveAs({
	        dataURI: data,
		fileName: "Narrative.pdf",
		proxyURL: "http://demos.telerik.com/kendo-ui/service/export"
	});     
});

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Template
Asked by
Jerry
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nikolay
Telerik team
Share this question
or