[Download Code]
Follow the link above and download the trial version of Dynamic PDF Merger. The installer will install both Dynamic PDF Merger and Dynamic PDF Generator Community Edition, and we will reference both in this project.
Start Visual Studio, and create an ASP.NET application in the language of your choice (VB.NET will be used for this article). Close and delete WebForm1.aspx. For the data source, we will use the Xtreme Traders sample database that is installed when you originally installed Visual Studio.
Since we will be exporting files in this application, we need to make sure the ASPNET user (Network Service in Windows 2003 Server) has MODIFY permissions on the application folder. Open your web root folder (usually c:\inetpub\wwwroot), right-click on your application's folder, and choose Properties. Open the Security tab, and add the ASPNET user (if not already present). Grant the ASPNET user MODIFY permissions, and click OK a couple of times to set the permissions.
Add a new Crystal Report to your project, and name the file Customers.rpt. Use the Report Wizard to create a Standard Report. (Note: The RPT files are included in the code download.)
The Data window (Figure 1 - click thumbnails for larger image) is the first step of the Report Wizard. Expanding the Access/Excel (DAO) node opens the Connection window (Figure 2). Navigate to the Xtreme Traders sample database located at C:\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports\Samples\Database\xtreme.mdb (if you are using VS 2002, the path will not include the year version). Click OK when done. You'll be back in the Data window, with the database selected and opened.
Next, we will create a report using the Customer table. Expand the Tables node, and double-click the Customers table to select it (Figure 3). Click "Next".
On the Fields tab, choose Customer ID, Customer Name, E-mail and Website (Figure 4). Click Finish to create the first report.
Create the second report by adding another Crystal Report and following the same steps as above. This time, name the file Suppliers.rpt, choose the Supplier table, and select all the fields in the table. Click Finish after the fields window to create the second report.
Add a new web form to the project, named default.aspx. Leave this page blank for now. (Note: default.aspx is included in the code download.)
One final step is to add references to Dynamic PDF Merger and Dynamic PDF Generator. Right-click on References, and select the ".NET" tab. Scroll down until you find "DynamicPDF Merger for .NET" and "Dynamic PDF Generator for .NET", and click Select. Click OK to finish adding the references. Make sure you add both references to your project.
We are now ready to test our reports, and set up the export functionality.