Direct Download as PDF in C1ReportHttpHandler

Originally Posted 1 October 2014, 5:43 am EST

  • Originally Posted 1 October 2014, 5:43 am EST

    Hello,

    In C1ReportViewer, their is an option to download as PDF but it opens the pdf file in a browser from where the user can save it.

    Is it possible that on the same click event of C1ReportViewer the file should prompt the user for the save location and then start downloading, instead of opening in a new tab?

    I am able to download the file but on a fixed path, it is not allowing me to prompt the user for saving it in some other location.

    Please help!!!
  • Reply

    Hello,

    You can export the report generated in C1ReportViewer using C1Report’s "RenderToFile" method. In this method you have to pass the path of the location where to save file and the format in which you want to save the file.

    For Example:


    report.RenderToFile(Server.MapPath("~/SavedReports/ReportPdf.pdf"), FileFormatEnum.PDF)


    To allow users to save the file you may use a Save dialog .
    Thanks,
    Deepak Sharma
  • Reply

    Hello Deepak,

    Thanks for the fast response!!!

    I am looking for an C1ReportViewer--> Save to PDF Click Event that calls the C1ReportHttpHandler..ashx in which if the exportformat is "Adobe PDF" then instead of redirecting to the "url" I wanted to download the report as PDF file directly.

    After populating the Report in C1ReportViewer.

    Hope this clears my issue.

    --
    Thanks,
    Rohit
  • Reply

    Hello Rohit,


    In that case I would suggest you to use a button instead of using the default save button and save the file to PDF directly to the desired location using the above suggested method. You may also remove the default save button and use your button to save the file to PDF format. To remove the button from tool bar you may use the code as follows:

    C1ReportViewer1.ToolBar.Items.RemoveAt(1);



    Thanks,
    Deepak Sharma
  • Marked as Answer

    Reply

    Thanks for your reply Deepak,

    I will do the same!!!



    Thanks,
    Rohit Jain
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels