cancel
Showing results for 
Search instead for 
Did you mean: 

Setting PrintOptions.PrinterName doesn´t work with SP2

Former Member
0 Kudos

Problem setting PrintOptions.PrinterName with Crystal Reports for Visual Studio 2010 Service Pack 2 (Version 13.0.2.469)

Framework: .Net Framework 4.0

Language: C#

Crystal Reports Version: Crystal Reports for Visual Studio 2010 Service Pack 2 (Version 13.0.2.469)

Problem: After changing some properties of objects in a report the delegation of PrintOptions.PrinterName doesnu2019t work any more. That means, itu2019s not possible any more, to assign a special printer to a report, that report is then always printed on the default printer.

Sample:

//create CrystalReport
CrystalReport1 rpt = new CrystalReport1();

//assign a Printer to the report
//here it works, the printer is set to rpt.PrintOptions.PrinterName
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";

//setting some properties of objects on the report
//effect: the assigned printer is gone, rpt.PrintOptions.PrinterName is empty
rpt.Section1.ReportObjects["txtTest"].ObjectFormat.EnableSuppress = false;

//assign a Printer to the report doesn´t work any more, this line of code has no effect, 
//rpt.PrintOptions.PrinterName remains empty
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";

This problem occurs since Service Pack 2 (Version 13.0.2.469), before the code was running without any problems.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,
I fight against this problem for a long time.
Even with the SP5 this problem still exist

But, perhaps, I found a solution for this problem (worked for me):

Dim _myCrystalReDoc as CrystalDecisions.CrystalReports.Engine
_myCrystalReDoc = new ....

_myCrystalReDoc.load (....)

Dim _rcd1 As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument
_rcd1 = _myCrystalReDoc.ReportClientDocument
_rcd1.PrintOutputController.GetPrintOptions.PrinterName = printerName

If _myCrystalReDoc.PrintOptions.PrinterName <> "" Then
       msgbox ("Yeah")
End If

In this way it works for me

Hope to have been of help

Bye

former_member183750
Active Contributor
0 Kudos

Many thanks for sharing Francesco.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

patrick_simons2
Participant
0 Kudos

Hi Ludek,

I ran across the same issue. Francesco's workaround did the trick.

Is there any official statement from the R&D? I cannot find the two Adapt-descriptions on the SAP-site.

I don't have to say that this behaviour is fatal; you instal a new Service pack, and then boum, an important feature no longer works.

BTW. I'm on SP9 now.

Tx,

Patrick

former_member183750
Active Contributor
0 Kudos

I looked in the ADAPT database and ADAPT01617264 is set as "Closed - Not Reproducible".

It may be helpful if you could provide a summary of the issue as you see it as well as code used and printer used.

- Ludek

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi All,

I think I have the same issue in printing crystal reports with the option "No Printer" checked on.

(I'm using CRVS2010 SP2, version 13.0.2.469 , C#,  .Net Framework 4)

Thanks Don to post the defect number ADAPT01617258 and  ADAPT01617264 above. But I can't find the any official note for these 2 issues, can someone please post the links for reference? Thanks a lot!

Besides, I try Marc's code above. It works for me but it takes around 2 -3 minutes for the report to print out. Does Marc or anyone having same performance issue I face?

Using the PrintToPrinter() (with "No Printer" check off), it takes ~30s to print the report only.

Best Rgds,

Cherry

former_member183750
Active Contributor
0 Kudos

ADAPT01617264 is resolved in SP3 for CRVS2010. Probably more by accident than intent as if this was by actual intent, it would be documented in the Crystal Reports for Visual Studio 2010 - Service Pack 3 - Fixed Issues wiki.

ADAPT01617258 is closed with no resolution. In a future SP for CRVS2010, there will be a new API (GetPrinterName) or something like it that will retrieve the printer name the report was created with.

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Hi Ludek,

Is there KB article published for ADAPT01617264 & ADAPT01617258 ? I want some offiical reference to share with my teammates.

Besides, if there is currently no fix for ADAPT01617258, is there any recommended workaround? Could Marc's codes be an option?


Thanks.

Cherry

PS, retested with another printer and no performance issue found. Probably it is a printer issue.

former_member183750
Active Contributor
0 Kudos

Is there KB article published for ADAPT01617264 & ADAPT01617258 ? I want some official reference to share with my teammates.

- Re. ADAPT01617264, see my previous post with a link to the Crystal Reports for Visual Studio 2010 - Service Pack 3 - Fixed Issues wiki. Also, note that you can search for KBs your self. Simply go to the top right corner of this web page. Select " of SAP" from the drop down next to the search box and type in your search criteria. ADAPT01617264 would have done it.

- Re. ADAPT01617258 - no Kb that I know of, but again, see the my post re. note from R&D. That's as "official" as it is.

Could Marc's codes be an option?

- Apparently it worked for him...

- Ludek

Former Member
0 Kudos

Hi Ludek,

Well, in fact ADAPT01617264 is not on the list of

Crystal Reports for Visual Studio 2010 - Service Pack 3 - Fixed Issues wiki.

Besides, searching ADAPT01617264 as suggested but no support note for it is found, only some with similar ADAPT no. So, I guess it was fixed by accident and KB is therefore not created.

Regards,

Cherry

Former Member
0 Kudos

This is an extremely critical issue for us as we have a lot of customers affected by this problem. Going back to SP1 is not an option because of other critical errors that has been resolved in SP2.

We'd appreciate if you could clarify a few things that will help us decide on how to proceed:

Will you fix the PrintToPrinter problem introduced in SP2 and when can we expect it?

Alternatively, when can we expect a fix (SP3 or hotfix?) to the problem described in ADAPT01608246? Our customers run the product on both 32 and 64 bit platform so we will indeed be affected by the problem. If the PrintToPrinter error is not going to be resolved we would then have to modify our product to use the suggested PrintOutputController class and distribute a new version of our product to our customers.

0 Kudos

Hi Karl,

Discovered this won't be fixed in the PrintController because it uses the ActiveX PrinterControl dll as a dependency which will not port over to 64 bit due to limitations with Microsoft dependencies and 64 bit IE.

So I discussed with the PM for our SDK's and he asked me to escalate this to R&D to see if we can resolve the issue with PrintToPrinter API and Printer name.

So the solution will be to use PrintToPrinter and therefore this name issue will get fixed also.

Curious, have you tried the other methods in P2P?

public virtual void PrintToPrinter(System.Drawing.Printing.PrinterSettings printerSettings, System.Drawing.Printing.PageSettings pageSettings, bool reformatReportPageSettings)

Member of CrystalDecisions.CrystalReports.Engine.ReportDocument

or

public virtual void PrintToPrinter(System.Drawing.Printing.PrinterSettings printerSettings, System.Drawing.Printing.PageSettings pageSettings, bool reformatReportPageSettings, CrystalDecisions.Shared.PrintLayoutSettings layoutSettings)

Member of CrystalDecisions.CrystalReports.Engine.ReportDocument

Check the SDK Help file for more info.

Thanks

Don

0 Kudos

Discovered this issue is a new bug. Both have been tracked, Setting Dissociate in code set the No Printer also.

ADAPT01617258 and ADAPT01617264

0 Kudos

As long as the Printer that the report was designed against is installed all should work.

Former Member
0 Kudos

Hello Don,

we have a standard application installed on 900 pcs. We never know the installed printers of all our customers, because of that we designed all reports with the no printer option set.

0 Kudos

Hi Guys,

A few others had create cases for this exact issue and we have now escalated the problem to R&D. Currently set for SP3 but not confirmed at this time if it makes it into that SP...

ADAPT01608246 - class not registered crystalprintcontrol in 64 bit application

And it's been Kbased - 1672555

Thank you

Don

0 Kudos

Hi Don,

So this means the PrintControll.dll isn't being registered in the 2010 SP2?

Is there maybe a fix-pack that would solve this issue? The problem lies in the installer of the redistributable installation of CR2010.

With kind regards,

Pieter Jong

-


Crystal Advice

http://www.crystaladvice.com

0 Kudos

correct, it's been slated for SP3, don't know at this time if it will make it in though...

Don

Former Member
0 Kudos

I am also experiencing this problem after upgrading from Crystal XI R2. I have the added complexity of only wanting to print certain pages so need to be able to control both the printer and pages printed.

I have to not design against a printer as, when printing multiple documents, it caused a memory leak in the earlier version of Crystal.

0 Kudos

Hello,

Check the case sensitivity of the printer name. I heard this resolved another persons issue.

I tested this API and it works fine for me.

Use this to get the name once you set the name:

MessageBox.Show("Printer Name: " + rpt.PrintOptions.PrinterName.ToString());

Don

Edited by: Don Williams on Dec 15, 2011 7:47 AM

Former Member
0 Kudos

In our application we get the printer names from:

 System.Drawing.Printing.PrinterSettings.InstalledPrinters

So I dont think that there´s a problem with the case sensitivity.

new Sample:

 //create CrystalReport
CrystalReport1 rpt = new CrystalReport1();

//assign a Printer to the report
//here it works, the printer is set to rpt.PrintOptions.PrinterName
rpt.PrintOptions.PrinterName = System.Drawing.Printing.PrinterSettings.InstalledPrinters[0];

//shows "Printer Name: Microsoft XPS Document Writer"
MessageBox.Show("Printer Name: " + rpt.PrintOptions.PrinterName.ToString());

//setting some properties of objects on the report
//effect: the assigned printer is gone, rpt.PrintOptions.PrinterName is empty
rpt.Section1.ReportObjects["txtTest"].ObjectFormat.EnableSuppress = false;

//shows "Printer Name:"
MessageBox.Show("Printer Name: " + rpt.PrintOptions.PrinterName.ToString());

//assign a Printer to the report doesn´t work anymore, this line of code has no effect, 
//rpt.PrintOptions.PrinterName remains empty
rpt.PrintOptions.PrinterName = System.Drawing.Printing.PrinterSettings.InstalledPrinters[0];

//shows "Printer Name:"
MessageBox.Show("Printer Name: " + rpt.PrintOptions.PrinterName.ToString());

And all our code works fine until we have installed SP2.

Former Member
0 Kudos

I detected something about this problem.

My test-project, and also our application contains older reports created before we have installed the SP2. If I add a new crystal-report now the code works fine, if I switch to the old report the error occurs.

In my test-project I can´t find absolut no differences between the new and the old report, both are blank reports with only one textobject on it. I have also compared the code-behind-file, no differences.

Can I send you our test-project for detecting this error?

0 Kudos

Hello,

I did a bunch of testing with SP2 and I have not gone back to SP1 to verify but here's my findings...

If you set the Printer then then print it will print to the new printer. The message box will not show the new printer name though.

If you check off the No Printer option in the report then the messagebox will show the new printer name.

Also, when saving the report with the No Printer option checked on it will not update the printer in the RPT file.

So use the messagebox off the System Printer object to show the new printer that was chosen.

I'll have to go check the Adapts to find out why this has changed.

Oh and I should mention also that changing anything in the report doesn't appear to make any difference.

Thanks

Don

Edited by: Don Williams on Dec 15, 2011 11:27 AM

Former Member
0 Kudos

Yes, you are right, the problem occurs only with the no printer option set.

It has nothing to do with newer or older reports, sorry, wrong idea..

But the problem remains, I cannot set the printer dynamically by code if the no printer flag is set.

We have a standard-application with round about 200 reports, all with the no printer option. I cannot change this option, because then the report format changes always a little bit.

0 Kudos

OK so question now is are you trying to save the report with the new printer setting? In my tests I could set it to the new printer and it would print, I just could not save the report with the new printer info, unless the no printer was checked off.

Are you using the PrintToPrinter method or PrintOutputController to print the report?

Thanks

Don

Update. I tested with SP1 and I see the exact same test results....

Edited by: Don Williams on Dec 15, 2011 1:48 PM

Former Member
0 Kudos

No, we use the PrintToPrinter method of the Report-Object.

I think we have now found a workaround for the problem using the printOutputController.

But I think also there´s a problem and a change of the behaviour with SP2.

Code that doesn´t work:

 //create CrystalReport (with the no printer flag is set)
CrystalReport1 rpt = new CrystalReport1();

//assign a Printer to the report
//here it works, the printer is set to rpt.PrintOptions.PrinterName
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";

//setting some properties of objects on the report
//effect: the assigned printer is gone, rpt.PrintOptions.PrinterName is empty
rpt.Section1.ReportObjects["txtTest"].ObjectFormat.EnableSuppress = false;

//assign a Printer to the report doesn´t work anymore, this line of code has no effect, 
//rpt.PrintOptions.PrinterName remains empty
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";

//prints always on the default printer
rpt.PrintToPrinter(1, false, 0, 0);

Workaround:

 //create CrystalReport (with the no printer flag is set)
CrystalReport1 rpt = new CrystalReport1();

//assign a Printer to the report
//here it works, the printer is set to rpt.PrintOptions.PrinterName
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";

//setting some properties of objects on the report
//effect: the assigned printer is gone, rpt.PrintOptions.PrinterName is empty
rpt.Section1.ReportObjects["txtTest"].ObjectFormat.EnableSuppress = false;

//assign a Printer to the report doesn´t work anymore, this line of code has no effect, 
//rpt.PrintOptions.PrinterName remains empty
rpt.PrintOptions.PrinterName = "Microsoft XPS Document Writer";
	
//Workaround with PrintOutputController
CrystalDecisions.ReportAppServer.Controllers.PrintOutputController printOutputController = rpt.ReportClientDocument.PrintOutputController;

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions o = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions();
o.PrinterName = "Microsoft XPS Document Writer";

//prints on the choosen printer
printOutputController.PrintReport(o);

Thanks a lot for your help.

0 Kudos

That would explain it....

P2P is a limited API and all of the issues we had with Printing were fixed in the OutPutController and no the P2P method since it was a CR Basic API and RAS is free now in CR for VS 2010 you might as well use it....

Yes they may have altered the method to "fix" something else. Possibly this is the way it should have worked from the beginning...

Thanks for the update

Don

Former Member
0 Kudos

Ok, now we tried to use the workaround with RAS because the problem with PrintToPrinter is now old ("legacy") code.

Effect: On my developing computer our project can print correct in Debug Mode (all Projects with target cpu: x86, 32 Bit)

In Release Mode (all Projects with target cpu: Any CPU, 64 Bit) no printing, error: "Class not registered - CrystalPrintControl".

On a Test-PC (Windows 7 64 Bit, without installed Visual Studio, but SAP Crystal Reports runtime engine for .NET Framework 4 (64-bit SP2 installed)

Release: error: "Class not registered - CrystalPrintControl"

I found a lot of hints for this error, with registering dll´s and something else, but nothing works..

Is there something more to install to use RAS?

0 Kudos

Is the Print driver a 64 bit version?

What printer are you using?

Former Member
0 Kudos

I have now tried all my printers (Windows 7 64 Bit):

An OneNote 2010 senden

Dymo LabelWriter 450

Fax

HP LaserJet P1006

Microsoft XPS Document Writer

Oki MC560(PCL)

All with the same result, error "class not registered - CrystalPrintControl".

I can try tomorrow more printers..

On 32 Bit Windows, the error also comes, but there I can fix it, registering the printcontrol.dll to system32.

I know how to register dlls on a 64 Bit Windows (with syswow64 etc.) but this doesn´t work, is there anywhere a different 64-Bit printcontroll.dll that I have to use?

0 Kudos

I just tried it myself here at home but I'm having problems with my D-Link router which uses a usb port for the printer... I get the same error but not sure if it's my Printer now or not. This was working for me, I updated hardware and had install Windows 7 64 bit OS on a SSD drive.

There is no printcontrol.dll in 64 bit folder and none in the 32 bit either, just in the CrystalReportViewer folder which suggests that dll is 32 bit only.

I'll have to ping the Developer and ask what dll the 64 bit print routine uses... But I'm sure this should work, may even be a registry issue between the syswow64 keys and system32.

Thanks

Don

And the other odd part is as you said:

"My test-project, and also our application contains older reports created before we have installed the SP2. If I add a new crystal-report now the code works fine, if I switch to the old report the error occurs."

New reports work but old ones don't, What ahppens if you update one of those old report manually and see if that works?

Don

Edited by: Don Williams on Dec 19, 2011 9:17 PM

Former Member
0 Kudos

Hello,

I found a lot of hints for the problem:

e.g. this works on 32 Bit - Windows.

[Link|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333633323336333933313330%7D.do]

But I found no solution for 64 Bit - Windows. I tried everything to register the PrintControl.dll with

%windir%\System32\regsvr32.exe and

%windir%\SysWOW64\regsvr32.exe

but nothing works.

How can we deliver the SP2 to all our customers without a lot of problems?

About this:

"And the other odd part is as you said:

"My test-project, and also our application contains older reports created before we have installed the SP2.

If I add a new crystal-report now the code works fine, if I switch to the old report the error occurs."

New reports work but old ones don't, What ahppens if you update one of those old report manually and see if that works?"

There I was on the wrong way, it has nothing to do with newer or older report, the problem occurs only with the

no printer option set. With all the old reports the no printer option was set and with the new ones by default it was not set. Wrong assumption, sorry.

0 Kudos

Hi Pascal,

No problem... I've seen strange things happen so just wanted to clarify....

As I said the dll seems to only be included with the 32 bit runtime so I have to check with the developers what a 64 bit app should be using...

And Rob, are you also having problems in 64 bit mode and if so this is something new, please post a new questions.

Thanks

Don