Converting ASP.NET to PDF

 I probably wouldn't be wrong if I said that most developers every now and then are tasked to present specific data contained in a webpage as a PDF document. There are two ways to do it:

  1. using the functionality of CrystalReportViewer's toolbar - this toolbar provides a button, which does exactly that. However, to use this approach you would have to actually display the crystal report on the page.

  2. programmatically convert the Crystal Report object into a PDF document using the Crystal Reports API

Below is the code for the second approach:

Dim report As CrystalReport1 = New CrystalReport1
SqlDataAdapter1.Fill(DataSet11)
report.SetDataSource(DataSet11)
report.ExportToHttpResponse (ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")

3 Comments

  • I will come back if it workd to me also

  • Could you please explain the second approach more detailed , like u have created object of crystalreport1

    Dim report As CrystalReport1 = New CrystalReport1

    Which dll contains this class?

  • To Dr. Suess,
    Actually PDF may be created definety by your about code,
    but the issue may be related to folder security in IIS.
    New PDF created may not have permission to Write file in the given Physical Path.

    Just Right click the destination folder on the server

    >>Properties >> Security

    and grant all permissions to the accounts
    1) IIS_WPG
    2) Internet Guest Account

    Try it once and send comments.

Comments have been disabled for this content.