Merging and Password Protecting PDFs Exported by Crystal Reports
page 2 of 6
by Richard Dudley
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 73674/ 46

Creating the Project

[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.)

Figure 1 - Data WindowThe 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).Figure 2 - Connection Window  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.

Figure 3 - Data WindowNext, 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.Figure 4 - Fields Window

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.


View Entire Article

User Comments

Title: Bookmark   
Name: Kirk
Date: 2010-02-05 7:36:29 AM
Comment:
How do you add bookmarks?
Title: You don't need to shell out on commercial components   
Name: Zarkonia
Date: 2008-05-28 8:09:20 PM
Comment:
Hi All,

Take a look at Pdftk...

Pdftk is free software (GPL) and it runs on Windows, Linux, Mac OS X, FreeBSD and Solaris.

It's a command line app - but with careful use of the SHELL command works like a charm in classic VB or the System.Diagnostics namespace in the .NET world.

I recommend it...
Title: Lib. Demo   
Name: XTemplar
Date: 2007-10-22 12:10:18 AM
Comment:
Dear Richard,
1.)May i have the demo. lib ??
My email: XTemplar@gmail.com
2.)What PDF version it support? All?
3.)What's the charges for it if it's suitable for me?

Thanks,
- XTemplar
Title: Problem for Merge PDF   
Name: Shekh Mohasin
Date: 2007-03-15 12:49:38 AM
Comment:
Hi Richard,
i have try ur code for Merage two PDF file, but in ur sources code i not found "ceTe" Libray file which is very imp it code to Mearge so, can u pls send me the Libray file
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.Merger

my MailId is
shekhmohasin@gmail.com

Thanks,
Shekh Mohasin
Title: SE   
Name: Yathish
Date: 2007-02-19 1:28:42 AM
Comment:
Hi Richard,

Is there any mechanism to open rpt files directly in Acrobat Reader instead of Crystal Report Viewer

Thanx,

Yathish M.P
Title: Passwords   
Name: Debbie
Date: 2006-12-28 3:53:25 PM
Comment:
What is the syntax for passing the password to the merger?
Title: How is it better than PDFLib for .Net   
Name: Richard Dudley
Date: 2006-10-26 9:31:09 PM
Comment:
Tech4U,

Only one way to find out--download the demo version and try it! "Load" depends on how large your reports are, and how your application is coded.
Title: How is it better than PDFLib for .Net   
Name: Tech4U
Date: 2006-10-24 2:07:32 PM
Comment:
Hi,
I've an existing app - Windows service, which generates multiple PDF files (Data retrieved from cubes and then Exported to pdf using Crystal) and PDFLib merges all the pdf files together into one file, but the problem is, as mine is a multithreaded app, the PDFLib fails badly and it allows me to select only a couple of Reports(which contains individual reports) but I want to allow user to select more than 5 reports or so, so that they can get all the 5 PDF files (including 100-200 individual pdf files). Can Dynamic PDF Merger handle this kind of load.
Title: Need Information about Continous PAging while merging reports   
Name: Brijesh (brijeshs@nous.soft.net)
Date: 2006-09-07 5:34:36 AM
Comment:
Hi Richard,
I have gone through your article of merging two crystal reports and its really very interesting.I just want to know that if we are using page numbers on both reports so while merging Reports whether the continous paging will happen.

In other words, if 1st report is having 5 pages and the second report is having 4 pages. When we merge these two reports, whether the second report will start from 6th page or Is there any option/setting that will make the second report to start from 6th page not from 1st page.

Any help would be appreciated.

Thanks
Brijesh Singh
Title: PW Protecting XML Files   
Name: Richard Dudley
Date: 2006-06-09 11:09:36 AM
Comment:
This really isn't the best place for that question, since this is an article on PDFs.

Since XML files are just text files, there's really not a good way to password protect them in the file system. Th ebest you could to would be to encrypt them with DPAPI somehow, or some other reversible encryption scheme.
Title: I have gone through the article and found to be interesting. I too have a problem and hope your component have the support feature. I have a requireme   
Name: I have gone through the article and found to be interesting. I too have a problem and hope your component have the suppo
Date: 2006-06-09 7:30:33 AM
Comment:
I have gone through the article and found to be interesting. I too have a problem and hope your component have the support feature. I have a requirement where I should password protect the xml files. This feature should be used from the .net desktop application. The software which I am developing for a client should use/read the xml files from the application. But these files should be password protected from the external drives/location, so that no one should be able to open these xml files.
Title: Reports with ASP   
Name: Richard Dudley
Date: 2006-03-27 1:32:48 PM
Comment:
Kevin,

You can generate Crystal Reports with ASP, but not in this example. This example uses the version bundled with Visual Studio .NET, and you'd have to use a .NET language.

To work in ASP, you'd need the retail version of Crystal Reports. There are tutorials available in the help docs and on the Business objects website.
Title: Generate report in ASP   
Name: Kevin
Date: 2006-03-27 3:14:41 AM
Comment:
Hi,

I wanted to know if it's possible to generate the report in asp instead of .net. And how to do it?

Thanks,

Kevin
Title: Add PW On Open   
Name: Richard Dudley
Date: 2005-11-28 9:31:36 AM
Comment:
Circle,

This article shows you how to add a password to a PDF exported from Crystal Reports. If you add a user password, the end user will be required to enter the password when the file is opened. You can use the same component I did, you just set a different property.
Title: Password protection on PDF File   
Name: Circle
Date: 2005-11-27 11:57:26 AM
Comment:
I m new on .Net & crystal report. Have develop project in Window Form and have to produce report in PDF format ultimately. So i prepare a crystal report and plan to use export function to generate the PDF file, but user request password protection on open the PDF file. Would like to have your advice.
Title: 3rd-party alternative (Visual CUT)   
Name: Ido Millet
Date: 2005-11-22 6:04:03 PM
Comment:
For those who are looking for a 3rd-party solution to do the above and more, my Visual CUT software can automate the exporting of Crystal reports to PDFs, the merging of these PDF files (including the merging of any bookmark information) and, optionally, adding page numbers, a table of contents, and password protection to the resulting merged pdf file.

Cheers,
- Ido
www.MilletSoftware.com
Title: Protecting XML Files   
Name: Richard Dudley
Date: 2005-10-24 3:19:27 PM
Comment:
Mallikarjun,

This has nothing to do with protecting XML files. Since XML files are plain text, they really can't be protected completely. One option might be to store the XML as an encrypted string, which you decrypt when you need to process the XML. If you have questions on how to accomplosh that, try the forums at http://asp.net.
Title: Project Manager   
Name: Mallikarjun
Date: 2005-10-22 11:28:03 PM
Comment:
Hi,

I have gone through the article and found to be interesting. I too have a problem and hope your component have the support feature. I have a requirement where I should password protect the xml files. This feature should be used from the .net desktop application. The software which I am developing for a client should use/read the xml files from the application. But these files should be password protected from the external drives/location, so that no one should be able to open these xml files.

Please assist me if your component has this feature.

Thanks in advance.
Title: Dynamic PDF merger   
Name: Shilpa
Date: 2005-10-13 11:41:27 PM
Comment:
Hi Richard,
I know you are discussing about different scenario of generating PDF files.But with my experience I don't prefer to use DynamicPDF merger.If you generate a PDF file some how and a add any kind of password to it and try to merge it with another PDF.It gives error!
Title: Dynamic PDF Merger   
Name: Richard Dudley
Date: 2005-10-05 8:12:55 PM
Comment:
Shilpa,

PDF documents created by Crystal Reports won't be password protected just ater they are created.

Perhaps your problem is in the way you are using the component? Are you supplying the password?
Title: Some problem with Dynamic PDF merger   
Name: Shilpa
Date: 2005-10-05 1:53:06 PM
Comment:
You article is good.But there is a problem in Dynamic PDF MERGER COMPONENT.
If any of the PDF document is already protected with password then you cannot merge them. It shows an error: "Document can not be decrypted. Invalid owner password."

Product Spotlight
Product Spotlight 



Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 9:29:39 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search