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

Export to PDF - filename is always coming back as "undefined"

3 Answers 263 Views
ClientExportManager
This is a migrated thread and some comments may be shown as answers.
Brent Hetland
Top achievements
Rank 1
Brent Hetland asked on 07 Mar 2016, 08:19 PM

I am using version 2016.1.225.40 of your asp.net for ajax controls.

I'm using ClientExportManager to export a PDF of a section of a page (a radgrid with page breaks).

It is exporting correctly, but when the browser gets the file, the filename is coming up as "undefined".

I've tried various things; nothing is working. The telerik tags and javascript are below.

I've tried it without the PdfSettings section in the clientexportmanager.

<telerik:RadClientExportManager  ID="PDFExportManager" runat="server" OnClientPdfExported="onClientPdfExported">

    <PdfSettings FileName="MetricSet" PageBreakSelector=".pdf-page-break" /> 
</telerik:RadClientExportManager>

I've tried the javascript by passing a pdfSettings to the export, and also by using set_pdfSettings. I get the same problem either way.

function onClientPdfExported(sender, args) { 
     document.getElementById("modalDivPDF").style.display = "none";
     document.body.style.cursor = 'default';
    } 

function pdfPageSection() { 
     document.getElementById("modalDivPDF").style.display = "block";
     document.body.style.cursor = 'wait';

     var pdfSettings = {
          filename: "MetricSet",
          margin: { top: 25, left: 15, bottom: 10, right: 15 },
          pageBreakSelector: ".pdf-page-break"
     }

        $ = $telerik.$; 
        var $dashboardPanel = $(".DashboardPanel"); 
        var manager = $find("<%= PDFExportManager.ClientID %>"); 
        manager.set_pdfSettings(pdfSettings);
        manager.exportPDF($dashboardPanel); //, pdfSettings); 
    } 

What am I doing wrong? Why do I get "undefined" for my filename???

Thanks,

Brent

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 10 Mar 2016, 11:23 AM
Hello Brent,

You can either set the FileName property in the PdfSettings tag:
<PdfSettings FileName="MetricSet" PageBreakSelector=".pdf-page-break" />

or use the set_pdfSettings() client-side method. In your case the reason setting the file name through the method did not work is because you are passing a "filename" property, but the correct one to use is "fileName":
var pdfSettings = {
    fileName: "MetricSet",
    margin: { top: 25, left: 15, bottom: 10, right: 15 },
    pageBreakSelector: ".pdf-page-break"
}


Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Brent Hetland
Top achievements
Rank 1
answered on 10 Mar 2016, 11:47 AM

Hi Ivan,

Thanks, that worked. I used "filename" because that is what the 2015.1.401 version of the Telerik documentation had in the example, as shown below (taken directly from the help file).

   var pdfSettings = {
        filename: "PDF-Export",
        proxyURL: "http://www.proxy.com",
        margin: { top: 25, left: 15, bottom: 10, right: 5 },
        paperSize: "A4",
        landscape: "Portrait",
        title: "PDF",
        author: "UserName",
        subject: "Export to PDF",
        keywords: "a keyword",
        creator: "John",
        date: new Date(2015, 10, 25)
    };

 

Regards,

Brent

0
Ivan Danchev
Telerik team
answered on 11 Mar 2016, 01:57 PM
Hello Brent,

The fileName property has not changed since 2015 Q1, so it must have been a mistake on our part to include a sample with an incorrect property name. Please accept our apologies for that.
Currently the documentation shows the correct property name.

Regards,
Ivan Danchev
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ClientExportManager
Asked by
Brent Hetland
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Brent Hetland
Top achievements
Rank 1
Share this question
or