cancel
Showing results for 
Search instead for 
Did you mean: 

CR2020 viewer print output is incorrect when PrintMode=PrintOutputController....

grchen168
Explorer
0 Kudos
571

Using Crystal Reports 2020 viewer in my C# WinForm application, after the data is loaded into the report, the RPT is correctly displayed in the viewer. 

And, when setting Viewer's PrintMode=PrintToPrinter, and then, click the print button of the viewer, the print-out is also correct.      So far so good.

But, this time, when setting the Viewer's PrintMode=PrintOutputController, and then, click the print button of the viewer, the print-out is incorrect!!  That is, the top & left margin of the print-out is too much.

Why the viewer in printmode='PrintOutPutController' does not produce the same result as print mode='PrintToPrinter' ??

Or, under the circumstance of setting PrintMode=PrintOutputController, what other measures should I take in my C# code in order to instruct the viewer print output as the same as when setting viewer's PrintMode='PrintToPrinter'?? 

 

Accepted Solutions (0)

Answers (9)

Answers (9)

DonWilliams
Active Contributor
0 Kudos

Download page has a Printer test app:

https://help.sap.com/docs/SUPPORT_CONTENT/crystalreports/3354091173.html

It has a routine to Set Printer and Select POC or P2P, use it to allow users to select and set printer:

Printing Crystal Reports in .NET

 

grchen168
Explorer
0 Kudos
Hi, Don, what you mentioned is : using code to prepare various parameters, then call the "PrintOutputController.PrintReport" or "PrintToPrinter" to print directly to specified printer.
grchen168
Explorer
0 Kudos
But, what my need is programatically show up the POC printer setup dialog to let user interact with. Is it possible?
DonWilliams
Active Contributor
0 Kudos
Look at my test app, it's all there and use POC in your code to select the printer.
grchen168
Explorer
0 Kudos

Thanks for the reply.

"use your own print Button rather than the one built into CR Viewers" - this is what I consider doing now.

I can hide the print button in the CR Viewer, but, another problem is : when my own print button is clicked by user, I hope to show up the POC printer-selection dialog, instead of PTP printer-selection dialog. Is that possible using C# winform? If yes, what library or component should be reference in my project? Any sample code available?

grchen168
Explorer
0 Kudos

Hi, Don,

Thank you for taking time to feedback observation.

You said: "Bottom line is POC is not capable of using your default margins." and "Nothing CR .NET POC can do",

But, I also test the rpt with data using Crystal Report Designer: Open the report file -> Choice "Print" from File menu, and the POC (not PTP) printer dialog pop up, and I again select "Cute PDF Writer" as printer and print.

The content of the print-out PDF is perfect and is the same as print out from PTP mode in your test application.

Any thoughts? 

DonWilliams
Active Contributor
0 Kudos

There is a difference... let me explain

Crystal Reports is built using Visual Studio C++ and it uses direct access to the DEVMODE structure, that's where Microsoft saves the Printer info.

So in Crystal Designer it directly accesses the DEVMODE structure when printing.

This is the same info SAVED in the RPT file. In Visual Studio using the Edit Report feature it use an Embedded Report Designer called CRAXDDRT.

It's a COM dll that wraps around crpe32.dll, that's the core report engine which uses the DEVMODE structure for printing.

So now the reason you see 2 different Print UI's is because P2P uses the saved info in the RPT file and doesn't use the .NET Printer Dialog.

I forget the actual names of the Printer Dialog dll's...

So when using P2P it uses the crpe32.dll to access the printer dialog.

When using a .NET App the POC API uses the .NET Printer Dialog box which then wraps around crpe32.dll and things are not 100%. Which is why the default margin in POC is .51 inches, note even if you set those values the .NET values is ignored, internally that is the smallest margin POC is capable of using.

The other thing you have to into account is the Custom Paper Size you are using, .NET will attempt to "match" the closest paper size available. It actually queries the Printer to see what paper size is closest to what is set in the Report.

To sum up:

CR Designer accesses DEVMODE structure directly.

CR Basic, which is what the Embedded Report Designer is in Visual Studio uses what is saved in the RPT file.

.NET POC API uses MS's .NET Printer Dialog box which is a .NET wrapper around the DEVMODE structure and is not always 100% compatible.

Also be aware those PDF print drivers are also not 100% perfect, when I worked at SAP I escalated a few issue with CurePDF and MS PDF printer, in all cases it was a limitation of those print drivers.

I suggest contacting CutePDF and explain to them you are seeing the top Margin being increased and see if they can fix their driver.

So again, bottom line is there is nothing CR can do to fix this.

FYI - I used my test app and rather than printing from the CR Viewers Print button I set the printer to my Lexmark printer, change it to landscape, best I could do and selected Legal paper. I did not see the header space as you did.

FYII - I did the same as you and the CR Viewers POC did the same as your test.

Work around, use your own print Button rather than the one built into CR Viewers. There was a test app that turned off CR Viewers print button but I can't find the KBA, it wasn't supported because the Button ID's can change any time..

grchen168
Explorer
0 Kudos

Deeply thank you for taking time to test it.

But, using the exactly same rpt file with the same data, if I open it with CR Designer and directly print it thru Designer's Print menu item, (the shown up printer dialog is the same as POC mode's printer dialog of .NET CR viewer component), and, again, choose the same Cute PDF Printer as target printer to generate PDF file, then generated PDF content is correct!! ("Correct" means the same as PTP mode's print-out)

If POC printing dialog and/or Cute PDF Printer cannot handle such custom-paper sized & margins report, why Designer's POC printing can produce correct result on Cute PDF Printer?

 

grchen168
Explorer
0 Kudos

Hi, Don,

The test file (rpt with data) is in the url (remove some columns for sensitivity concerns):

test.rpt

Hope to print the report using POC mode to achieve the same result as using PTP mode via CR viewer's (embed in my C# winform) built-in print button.

 

grchen168
Explorer
0 Kudos

Hi, Don,

By the way, following your instruction, I also open the report in CR Designer and select the printer, save it and test again, and also enable Dissociate printer and test again, all result is the same when printing using POC mode with the viewer's print button.

Or is it appropriate sending you the rpt file with data?

Anyway, any feedback/guidance is highly appreciate.

grchen168
Explorer
0 Kudos

Hi, Don,

I try all the combinations of either checking/unchecking "No Printer"  and/or checking/unchecking "Dissociate...",

but still the same print-out result: that is, when printing via PrintButton of the CR viewer control and using POC PrintMode, then  the print-out  is all the same.

Note: if printing using PTP PrintMode , then the resultant print-out is what expected.

What else should I pay attentaion to?

 

 

grchen168
Explorer
0 Kudos

Hi, Don, 

Thank you for reply.

My default printer is Cute PDF Writer.

And, I try my rpt file with data with your application (RAS10_CSharp_Printers.exe), 

When the  "Viewer Print Mode" is "PrintToPrinter" selected, then click the viewer Print button, the print out is correct.   But, if the "Viewer Print Mode" is "PrintOutputControl" selected, then the print out from the viewer's Print Button is not correct.

Please have a look at the attached file.

 

 

DonWilliams
Active Contributor
0 Kudos

What SP are you using and version of VS?

See if you get the same issue using my Printer test app:

Printing Crystal Reports in .NET

Save a report with data, open it in the test app.

Select the printer and Set Printer button.

See if that works.

Also note, you must set the Landscape/Portrait in your app, see the sample for more details

grchen168
Explorer
0 Kudos
The CR engine is v13.0.36, and VS is VS2015.
grchen168
Explorer
0 Kudos
And thanks Don's reply. But, as said, when the viewer's PrintMode='PrintToPrinter, then the viewer's print button can produce correct print-out. Question is : I just merely switch the viewer's PrintMode property value to 'PrintOutPutControl', why the print-out of the same viewer's print button can not be the same as when the property value is 'PrintToPrinter'?print-out by
DonWilliams
Active Contributor
0 Kudos

What is your default printer set to?

If you use my test app and select a real printer what does it do and show for margins?

DonWilliams
Active Contributor
0 Kudos
Mmmmmm... yes, send me your report with dummy saved data. I'll have a look at it and see if I can duplicate your issue...
DonWilliams
Active Contributor
0 Kudos

Thanks for the report, I see the problem...

CutePDF is not capable of using your margins when using POC.

In your screen shot of my test app notice the margins are set to 1 inch.

POC is only capable of setting/using .51 inch margins so it's adjusting the top of the page margin.

When I set it to .51, save the report now I see:

DonWilliams_0-1730815298131.png

The other issue is you are using a custom paper size.

Not sure if CutePDF is capable of using margins that small, you have them set to .394, POC is adjusting accordingly.

When saved and opening in test app note the change:

DonWilliams_1-1730815486596.png

And you have some custom paper size defined which is not a default paper size listed in CutePDF.

Bottom line is POC is not capable of using your default margins.

P2P is, because it uses the values saved in the report.

Nothing CR .NET POC can do, it's just how it works.

.51 is the minimum Margin POC can use, that adjusted by CutePDF alters the layout.

So when using this report always use the P2P API to print. Note also you can't adjust P2P printer info, that too is the norm.