Click here to Skip to main content
13,835,880 members
Rate this:
Please Sign up or sign in to vote.
See more:
Actually I have a report in Crystal Reports. What I want to do is, "When I click on a button then it will convert dat report into .pdf file into a specified location" :-\

I'm using C# (window application)
Updated 2-Feb-10 12:12pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


May be the following code will help you. Pass your loaded report file to the following function and probably it would open a pdf file.

Private Sub PrintInAcrobat(ByVal rptDoc As ReportDocument)
            Dim Fname As String
            Dim crExportOptions As ExportOptions
            Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
            rptDoc.PrintOptions.PaperSize = PaperSize.PaperA4
            rptDoc.PrintOptions.PaperOrientation = PaperOrientation.Portrait
            Fname = Server.MapPath(".") & "\" & Session.SessionID.ToString & ".pdf"
            crDiskFileDestinationOptions = New DiskFileDestinationOptions
            crDiskFileDestinationOptions.DiskFileName = Fname
            crExportOptions = rptDoc.ExportOptions
            With crExportOptions
                .DestinationOptions = crDiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
            Response.ContentType = "application/pdf"
        End Sub

Hope it helps!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

In my web project crystal reports in built print option was used
and on print a new web window gets opened in which All or Pages option is selected
If pages option selected values in From and To text box can be entered
I want to get these values to enter in to my database but could not find any event for inbuilt print button

So i decided to go with my own print button
which will open a new window from where i will select ALL or Pages
and if Pages is selected values in From and To textbox
that is from which page to which page i want my records in pdf

I used the above code in solution 1 to convert my report in to PDF
this converts all the records which are opened in report(.rpt)
i want to convert only few records like
4th to 8th only
Please suggest.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you can export a crystal repport to the specified format (.pdf)
with this code

CrystalReport1 cr = new CrystalReport1();

string n = "c:\your specified location";
cr.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, n);
Sandeep Mewara 11-May-10 15:30pm
Why did you replied 3 months old post? Whats the use?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web05 | 2.8.190114.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100