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

4 posts, 1 answers
  1. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 07 Mar Link to this post

    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

  2. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    837 posts

    Posted 10 Mar Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 10 Mar in reply to Ivan Danchev Link to this post

    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

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    837 posts

    Posted 11 Mar Link to this post

    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.
Back to Top