How to change the default PDF filename?

16 posts, 0 answers
  1. Feedback
    Feedback avatar
    15 posts
    Member since:
    May 2007

    Posted 08 Aug 2007 Link to this post

    When a user clicks on the "Export" button of the ReportViewer, he or she can choose to export the report to a PDF file because I made sure to reference the ImageRendering dll in my project.

    How can I change the default filename to which the report will be exported?  I need to change this at run time, based on which report they have run and on which products.

    Is there a way to set this?  Right now, it always exports to "Report.pdf" and that isn't going to work for this project.

    I looked in the documentation, and in this forum, and have come up empty for setting the filename when the ReportViewer is being used (direct export to PDF is covered quite nicely here in the forum, however.)

    Thanks!
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2477 posts

    Posted 08 Aug 2007 Link to this post

    Thank you for the nice question, Matthew.

    The default name of the file, when exporting a report, is the name of the report class plus the appropriate extension. As of now, there is not way to override that name at runtime. You can create different report classes with different names that inherit from your original report, and each of them will be exported with its appropriate name.

    We will consider adding this functionality in a future version. There is no workaround I can suggest at the present moment.
     

    Best wishes,
    Rossen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Joel
    Joel avatar
    177 posts
    Member since:
    Oct 2006

    Posted 24 Sep 2007 Link to this post

    I was curious if the ability to programatically name the pdf file has been added in the Q2 release?  Our standard class naming convention makes for a very odd user experience.  This would be important functionality in the future if it does not exist yet.
  4. Svetoslav
    Admin
    Svetoslav avatar
    649 posts

    Posted 25 Sep 2007 Link to this post

    Hi Joel,

    To our great regret we didn't got enough time and postponed the feature for the next version, due at the end of the year. Sorry for the delay.
     
     
    Kind regards,
    Svetoslav
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Gary C
    Gary C avatar
    8 posts
    Member since:
    Nov 2008

    Posted 09 Oct 2009 Link to this post

    Hello,

    Has this feature has been implemented in the latest version? (i.e. changing the export file name at runtime). If so, how do you do it?

    Thanks,
    -Gary
  6. Steve
    Admin
    Steve avatar
    10940 posts

    Posted 12 Oct 2009 Link to this post

    Hello Gary,

    You should use the DocumentName property of the report for this purpose.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Dan
    Dan avatar
    4 posts
    Member since:
    Sep 2012

    Posted 28 Feb 2013 Link to this post

    This question is a few years old now.  Is there a solution for this yet?  I just had a customer request the file be named to something other than the class name.
  8. Squall
    Squall avatar
    181 posts
    Member since:
    Feb 2011

    Posted 01 Mar 2013 Link to this post

    Have you tried to set the Report.DocumentName property?
  9. Dan
    Dan avatar
    4 posts
    Member since:
    Sep 2012

    Posted 01 Mar 2013 Link to this post

    Yes.  About 2 minutes after I posted this I found another thread which described how to do this.
  10. Andrew
    Andrew avatar
    4 posts
    Member since:
    Aug 2019

    Posted 27 Aug Link to this post

    Hello,

    I know this post is quite old, but this is still not working for me. I tried setting Report.DocumentName from C# but export still saves the file using the class name in my report. I'm changing Report.DocumentName inside the Report_ReportNeedDataSourceEvent. Should that work fine?

    I'm using Telerik Reports version 13.1.19.618 (runtime version v4.0.30319)

    Thanks!

  11. Andrew
    Andrew avatar
    4 posts
    Member since:
    Aug 2019

    Posted 27 Aug in reply to Andrew Link to this post

    Quick update. I'm still not able to change Report.DocumentName from C#, but I did so in the report designer -> Properties -> Settings -> DocumentName by building an expression like: ='SpendingSummary_by' + IIf(Len(Parameters.PersonID.Value) > 0, 'Person', 'Product')
  12. Neli
    Admin
    Neli avatar
    147 posts

    Posted 30 Aug Link to this post

    Hello Andrew,

    The approach you have found is the recommended one.
    Basically, we advise avoiding modifying reports' structures in events. You should be able to set the DocumentName property in the NeedDataSource event. For more details, please check Changes on items in report events are not applied and Modifying or Creating a report at Run-Time KB articles

    Regards,

     
    Neli

    Progress 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
  13. Andrew
    Andrew avatar
    4 posts
    Member since:
    Aug 2019

    Posted 30 Aug in reply to Neli Link to this post

    Hi Neli, okay, thank you for confirming.
  14. Joel
    Joel avatar
    177 posts
    Member since:
    Oct 2006

    Posted 30 Aug Link to this post

    Andrew, 

    Here's the vb code we use.  It works.  We make a reportbook since sometimes we add cover pages or additional reports and set the filename there.  If you only have a single report you can ignore the first IF statement.  Hope it helps

     

        If _CoverType > 0 Then
            Select Case RepType
                Case 5, 22, 27, 30, 34, 36, 38, 42, 43, 46, 70  ' portrait
                    CoverPage = New Reporting.CoverPage(_dtc, stitle, bmp)
                Case Else
                    CoverPage = New Reporting.CoverPageLandscape(_dtc, stitle, bmp)
            End Select
        End If
     
        Dim repbook As New Telerik.Reporting.ReportBook
        If _CoverType > 0 Then
            repbook.Reports.Add(CoverPage)
        End If
        repbook.DocumentName = "MyPDFFileName"   '<---This is your PDF file name
        repbook.Reports.Add(thereport)
        thereport.DocumentName = repname
        myreport.Report = repbook ' thereport
    End If
  15. Andrew
    Andrew avatar
    4 posts
    Member since:
    Aug 2019

    Posted 30 Aug in reply to Joel Link to this post

    Joel, thanks for sharing that. Unfortunately I'm just working with standalone reports and not creating them within a ReportBook, but good to know that is an option.
  16. Neli
    Admin
    Neli avatar
    147 posts

    Posted 02 Sep Link to this post

    Hello Andrew,

    When you set the DocumentName property, the value is not used when exporting from the Standalone report designer. The report filename will be used instead. However, if you integrate the report in some of the report viewers then the value of the property will be taken into account and the report will be saved with the new name. 

    Regards,
    Neli
    Progress 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
Back to Top