Link to home
Start Free TrialLog in
Avatar of Yagaman
YagamanFlag for United States of America

asked on

Speed up alternating between printer trays for Crystal Reports in vb.net

Hello Everyone,

I have a program written in VB.NET 2008 and I need to alternate back and forth between paper trays for our Crystal Reports (Crystal Reports 2013); every other page needs to be on yellow paper. All of the vb.net calls using the Crystal ReportDocument do not work.  

Here in Experts Exchange, I found the reason for my problem (it seems to be a Crystal issue with their API calls) but I also found a "brute force" workaround.

The solution that I found was a 5 year old post here in Experts Exchange:
Experts Exchange > Database > DB Reporting Tools > Crystal Reports > Select printer tray for Crystal Report
However, on our HP 8150 printer the workaround is unacceptably slow in switching printer drivers.

This is the workaround submitted by byundt:
"A brute force workaround I have used when printing from Excel is to install more than one instance of a printer. You can then adjust the default settings on the new instance of the printer so that you get the paper tray you need. Then all you need to do programmatically is to choose which printer instance you want to use."

It worked perfect at almost normal speed on our Minolta Bizhub C650, but it is way too slow on our HP 8150.

Does anyone know how to speed this up; or am I doomed on this printer and it's inability to quickly respond to the driver change?

Here is the code that I am using (where intI is the report that needs to be yellow and gcrReport is the ReportDocument):

Dim Printer As New System.Drawing.Printing.PrinterSettings
strPrinterName = Printer.PrinterName

If strPrinterName.Contains("8150") Then
      If intI = 2 Then
            gcrReport.PrintOptions.PrinterName = "8150_Yellow"
      Else
            gcrReport.PrintOptions.PrinterName = strPrinterName
      End If
      gcrReport.PrintToPrinter(1, False, 0, 0)
ElseIf strPrinterName.Contains("C650") Then
      If intI = 2 Then
            gcrReport.PrintOptions.PrinterName = "Bizhub C650_Yellow"
      Else
            gcrReport.PrintOptions.PrinterName = strPrinterName
      End If
      gcrReport.PrintToPrinter(1, False, 0, 0)
Else
      'move on with default settings all on white
      gcrReport.PrintToPrinter(1, False, 0, 0)
End If

Thanks in advance for any help.
Avatar of Mike McCracken
Mike McCracken

Is this a multiple page report or are you printing multiple copies of a report?

mlmcc
One of the 3rd-party Crystal Reports Desktop Schedulers (see list at http://kenhamady.com/productlinks/default.html#desktopsched) provides an API that you can call from your application (or trigger directly via a batch file) to automate the process of exporting a Crystal report to PDF and print the PDF to different paper trays based on invisible Crystal formulas acting as text tags for directing the printout to different trays.
Avatar of Yagaman

ASKER

mlmcc,

The reports could be one or more pages; however a complete report first prints in white and then the next report, which is basically the same report only going to a different recipient, prints in yellow.
Avatar of Yagaman

ASKER

IdoMillet,

I will be looking at those 3rd party Crystal Reports Desktop Schedulers here shortly. But I was wondering if you had a particular one in mind that you may have used for something like this; or do I need to look at all of them to see if one might work for me?
The tool he has in mind is Visual Cut.  Since it is his tool he can't self-promote due to EE rules.

mlmcc
Avatar of Yagaman

ASKER

mlmcc,

Ah, I see. Okay, I will take a look at that.

However, I will have to check with my manager about spending any money on this project. They are a little apprehensive seeing that I have made it work on both printers, just not fast enough on the HP 8150.

I was wondering if you had any more input on a work around?

Thanks to both you and IdoMillet for your responses.
Your use scenario is simpler than I thought.  I don't think a 3rd-party tool would be a solution to the speed issue.  It's probably something related to report content x printer interaction (scaling to fit?  font support?).

Your first step should be to see what happens if you send the report to the same printer A twice. Same printer B twice.  Is one of them much slower, are both slow? In other words, I don't think it's the printer change that's causing the problem, but this test would confirm/deny that theory.
Avatar of Yagaman

ASKER

There is no scaling or font differences between any of these reports just how many pages; and most are one page. Also, I can't send the same report twice in a row from our print program (which is another custom program) because when I pick just one it will ask me to confirm the print after each click of the print button. And for some reason selecting more than one copy doesn't work.

(Forgive me but these are all legacy programs that were built by someone else who is no longer here and I was hired to take over and continue to make things work.)

But your idea is a good one so I went ahead and sent two reports (each printing 2 copies of the reports for the different recipients)  in a row to each printer without alternating the printer drivers and both printers printed at the normal expected speed.

But when I send the same reports so that they will print one copy of each report white and one copy yellow (alternating the printer drivers) those same reports print at the same speed on the Minolta Bizhub as the above test, but on the HP 8150 it was much slower than the above test.

It appears to me that it is the switching of the drivers with the HP 8150. Is it possible that HP is just slow on the re-initializing of the driver and just not as robust of a printer?
If you are switching the printer driver on the fly, Crystal has to change the driver and regenerate the report using the driver.  That could slow things down.

mlmcc
Good point, mlmcc, though the driver is the same (just 2 logical printer names for the same physical printer with different default tray).  

In any case, if the printer switch causing a report re-rendering is the issue then I suggest you export to PDF and then print the pdf to the 2 printers.
Avatar of Yagaman

ASKER

Yes, good point mimcc; so it is the changing of the drivers. I just had not thought of the why, thanks.

And thank you IdoMillet, for the PDF idea. I guess I am disappointed in the HP, since, as I mentioned, my code works so well on the Minolta Bizhub.

Oh, well, I will let you know how the PDF idea works.

Thanks to you both.
Avatar of Yagaman

ASKER

Good Morning,

Well, exporting to PDF and then printing did not change anything.

But what I have noticed in all scenarios with the HP 8150 is that every time it prints to the yellow paper tray it is slow; like it has to "think about it" with each print. This happens even when I set the default printer to the HP 8150_Yellow, which has the default tray set to the yellow tray, and then print everything in yellow. It is still pausing after each page, acting like it is still switching to yellow from another tray.

I also noticed in all scenarios, when I am switching back and forth between trays, that it switches from the yellow tray back to the white tray really fast but then when it goes to the yellow it stops and "thinks" again, slowing the process way down.
ASKER CERTIFIED SOLUTION
Avatar of Yagaman
Yagaman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yagaman

ASKER

Because, although the suggestions were good, none of them solved the issue. So I have to go with the code that I had already written.
Thank you.
Avatar of Yagaman

ASKER

Hello mlmcc and IdoMillet,

I wanted to come back and let you know that I figured out the problem on the HP 8150 printer of switching back and forth between 2 different paper sources.

The HP 8150 universal printing PCL 6 driver is what HP's website says to use with Windows 8, and works perfectly for normal printing. However, instead of printing the document, it would print out an Invalid Attribute exception when trying to switch drivers. So, I switched to the HP LaserJet 8150 PS class driver, which worked but only at the unacceptably slow speed of 5 seconds when switching to tray 2!

Well, my users could not live with this slower speed, so I continued to research the issue. I finally decided to try the older HP 8150 PCL 5 driver, and, voila, it worked and at normal speeds! It switches trays as fast as if you were printing everything on the same tray!

I should have tried this to begin with even though HP suggested the PCL 6 drivers. Oh, well, praise the Lord, it is now working as it should.

I thought I should come back to post this for anyone else with this problem.

Thanks again.