We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Printing discrepancies between Crystal Report Designer and C# code

DevMan
DevMan asked
on
Medium Priority
511 Views
Last Modified: 2012-05-06
I am having some inconsistencies between printing to a text file from Crystal Designer and printing to a text file via the Crystal Reports SDK for .NET. I am using Crystal Reports XI Release 2 SP4 and when I print my report to a file, using a printer and the Generic/Text print driver, the report comes out fine. But when I try to print the same report to a file, using the same printer, via .NET code, the text looks like it is falling off the page. We are wanting to run a bunch of reports in batch and output them to text.

The report was written using a PCL printer and not the Text Printer.

Attached is a snippet of my batch code.

Thanks.
ReportDocument report;
 
// Loading of the rpt file and setting of authentication credentials
 
System.Drawing.Printing.PrinterSettings _printerSettings = new PrinterSettings();
System.Drawing.Printing.PageSettings _pageSettings = new PageSettings();
report.PrintOptions.CopyTo(_printerSettings, _pageSettings);
 
// Set the report to use the print to file printer using the Generic/Text driver
_printerSettings.PrinterName = "TextPrinter";
_printerSettings.PrintToFile = true;
_printerSettings.PrintFileName = this.outputPath;
 
// Run the report
report.PrintToPrinter(_printerSettings, _pageSettings, false);

Open in new window

Comment
Watch Question

Author

Commented:
Another piece of information that might help is that this is a console application, not a web app.
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Try changing the printer to the printer you are going to use to print to.

Crystal uses the printer driver to render the report.  Changing the driver can cause problems like this.

Maybe these articles will help

How Printer Driver Options Affect a Report
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a09051e9-721e-2b10-11b6-f9c65c64ef29

Printer Driver Dependency: How to Design Reports that Print Consistently in Different PC Environments
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40e40899-721e-2b10-b084-c7ed76af46f1

mlmcc

Author

Commented:
In both Crystal Designer and in my code, I am printing to the exact same printer and driver.  Does Crystal Designer perform some additional formatting before sending the report to the printer?

Author

Commented:
mlmcc,

Thank you for the link to the document.  I have gone back and modified my code to reset the page orientation and paper size when I set which printer to use, as recommended in the document.  That still has not fixed the problem.

For example, the report was designed with a CUSTOMER NUMBER label for a field.  When I print to the Text Printer from Designer, the label comes out as:

CUSTOMER NUMBER:

When I print to the exact same Text Printer from my code, the label comes out as:

CUSTOM N:
                 UMBER

Author

Commented:
Both the Crystal Designer and .NET code are running on the same machine.
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
I don't know.  I don't recall seeing anything in the Crystal KB about an issue like that.

I'll look to see if there is something.  Most of the issues are font size.

mlmcc
Commented:
I have discovered what the problem is.  The report was not designed in a manner which was not printer driver independent.  Modifying the report format appears to be resolving the solution.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.