locked
Exporting a report to PDF RRS feed

  • Question

  • What code can I use to export a report in microsoft reportViewer to a .PDF file?

     

    I do not want to use the export button embedded in the report viewer. I have to code my own button.

    Can anyone tell me how to do this?


    If it feels like life is crashing down on you, check for null references. tgf-47@hotmail.com
    Monday, July 19, 2010 10:13 AM

Answers

  • Hello tgf-47,

    Thanks for your post.

    You could use ReportViewer.LocalReport.Render() and specifying "PDF" for the format. More information, you could see the following link which processes the report and renders it in the specified format. Hope it helps.
    http://msdn.microsoft.com/en-us/library/ms251839(VS.80).aspx
    (LocalReport.Render Method (String, String, out String, out String, out String, out String[], out Warning[]))

    If you have any problems, please feel free to follow up.

    Best regards,

    Liliane


    Please mark the replies as answers if they help and unmark them if they provide no help. Thanks
    • Marked as answer by Liliane Teng Monday, July 26, 2010 11:02 AM
    Saturday, July 24, 2010 10:01 AM

All replies

  • Check this information:

    http://www.eggheadcafe.com/community/aspnet/14/12160/convert-a-crystal-report-viewer-report-to-pdf.aspx

    http://www.codeproject.com/KB/vb/JatsArticle1.aspx

     

    Try this code:

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared


    Dim CrystalReportDocument As ReportDocument
    Dim CrystalExportOptions As ExportOptions
    Dim CrystalDiskFileDestinationOptions As DiskFileDestinationOptions

    Dim Filename As String
    CrystalReportDocument = New ReportDocument()
    CrystalReportDocument.Load("Path" & "CrystalReportTemplateName.rpt")

    Filename = "C:\FileName.pdf"

    CrystalDiskFileDestinationOptions = New DiskFileDestinationOptions()
    CrystalDiskFileDestinationOptions.DiskFileName = Filename
    CrystalExportOptions = CrystalReportDocument.ExportOptions
    With CrystalExportOptions
    .DestinationOptions = CrystalDiskFileDestinationOptions
    .ExportDestinationType = ExportDestinationType.DiskFile
    .ExportFormatType = ExportFormatType.PortableDocFormat
    End With
    CrystalReportDocument.Export()


    Naldo
    Monday, July 19, 2010 8:27 PM
  • Thing is, microsoft reports and crystal reports are 2 very different things. I need a code for msReports. Do you perhaps know how to do it in msReports? :-)
    If it feels like life is crashing down on you, check for null references. tgf-47@hotmail.com
    Tuesday, July 20, 2010 6:58 AM
  • Hello tgf-47,

    Thanks for your post.

    You could use ReportViewer.LocalReport.Render() and specifying "PDF" for the format. More information, you could see the following link which processes the report and renders it in the specified format. Hope it helps.
    http://msdn.microsoft.com/en-us/library/ms251839(VS.80).aspx
    (LocalReport.Render Method (String, String, out String, out String, out String, out String[], out Warning[]))

    If you have any problems, please feel free to follow up.

    Best regards,

    Liliane


    Please mark the replies as answers if they help and unmark them if they provide no help. Thanks
    • Marked as answer by Liliane Teng Monday, July 26, 2010 11:02 AM
    Saturday, July 24, 2010 10:01 AM