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

Export tp PDF

2 Answers 220 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 13 Nov 2007, 12:48 AM
I have seen examples that export to PDF in a web application.  Can you programatically export to PDF from Winform application

2 Answers, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 1
answered on 13 Nov 2007, 10:40 AM
Found the answer
0
Chavdar
Telerik team
answered on 13 Nov 2007, 04:31 PM
Hello Scott,

It is great that you have managed to find a solution on your own. However, here is our suggestion and a possible solution for those who are still interested:

    void buttonExport_Click(object sender, EventArgs e)
    {
        Report report = new ShapesReport();
        this.SaveToFile(report, "PDF", @"C:\Reports\");
    }     

    void SaveToFile(Report report, string exportFormat, string reportsLocation)
    {
        string extension;
        string mimeType;
        Encoding encoding;

        byte[] reportBytes = Telerik.Reporting.Processing.ReportProcessor.Render(exportFormat, report, null, out mimeType, out extension, out encoding);           
        string reportName = string.IsNullOrEmpty(report.Name) ? report.GetType().Name : report.Name;
        reportName += "." + extension;

        using (FileStream fs = new FileStream(reportsLocation + reportName, FileMode.Create))
        {
            fs.Write(reportBytes, 0, reportBytes.Length);                                               
         }           
    }


Let me know if you have any additional questions.
Thank you in advance

Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 1
Chavdar
Telerik team
Share this question
or