Link to home
Create AccountLog in
Avatar of cheyanne040277
cheyanne040277

asked on

Suggestions on Performance Improvements on generating a pdf from a Crystal Report in a VB.NET application

We are generating a pdf from a Crystal Report using Crystal 2008 in our VB.NET application (SQL Server database). We have found that it takes 12 seconds to generate the pdf. The data retrieval in Crystal only takes 1 or 2 seconds so I do not think the report itself is the issue. We are hoping for suggestions that will improve the time it takes to call the report, generate the report and create the pdf.

1.      Instantiating the JTCrystalReport object takes a bit of time. This inherits Crystals’ ReportDocument and just has a single additional property so it does appear that it’s the instantiation of  the native object causing the delay.
2.      Right after we create the JTCrystalReport object, we load the report which also takes some time:
                crystRep.Load(strRPTFile, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByDefault)

I’m wondering if there is a way to pass in a different parameter that will make it load faster?

3.      Then the call to ExportToStream takes several seconds:
objStream = mCrystalReport.ExportToStream(objExportFormatType)

All of these are outside of our control and give unacceptable performance time when the user performs the task that triggers the generation of the report.
Avatar of Mike McCracken
Mike McCracken

What report parameters are you passing?

Does the report do complex filtering or calculations?

Other than changing the report I don't thin you can speed up the export process.

mlmcc
Avatar of cheyanne040277

ASKER

I'm passing a parameter that is the primary key for that record. I even created a report that just prints the parameter and it still takes 12 seconds.
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Perhaps instead of generating the report, you could print it to a PDF printer/writer that would generate the report.

When you preview the report, how long does it take?

I realize 12 seconds seems like a long time but that is actually fairly fast for Crystal.

Why do you need it faster?  ARe there time critical things outside the program?

mlmcc
The user is generating around 40 reports on average at the same time, so has to sit and wait for 40 x12 seconds, the least amount they generate is 3 at one time. This is just counter productive to the user's need to get the time critical job done.

ryanmccauley, is your suggestion to replace Crystal as the method to generate the reports? If so, that is not really a feasible option at this point.
Can you multi-thread the report creation? If all you're waiting on is the component, perhaps you can spawn these reports on secondary threads and then let them all complete in their own time. For examples of how to do this, check out the ThreadPool in .NET - it will let you easily spawn new threads without having to manage them explicitly, and then they can each generate one report in the background and terminate, so the "wasted time" is done simultaneously, dropping the amount of time to used has to wait.

Here's a basic example of background processing using the ThreadPool:

http://www.codeguru.com/columns/vb/article.php/c6553

If you'd not worked with threads before and would like some more detail, I can try to find a more complete introduction, though this one covers the basics and gives an example.
There is also a limit of 5 Crystal connections at any one time.  You may also be running into this restriction.  A report may use several connections.

How are they running the reports?

Can they be run from an application that just runs 1 until it is complete then starts the next or are there parameters to enter?

mlmcc
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.