Printing Crystal Reports – Custom Paper Sizes
Printing Crystal Reports in .NET
Printing Crystal Reports is a series of documents that explain how Crystal Reports behaves when viewing and printing using the various buttons and API’s. The series is authored by Don Williams and Ludek Uher, both Senior Support Engineers at AGS Product Support. The documents applies to Crystal Reports 2011 and above and SAP Crystal Reports, Developer Version for Visual Studio .NET only.
Using Label printers requires a specific work flow so the Engine can do the following:
- Find the exact Label printer the report was built against
- Find as close as match as it can.
- Use the User defined paper size, as saved in the report
- Look for the closest match for the printer device and paper size and orientation.
- Properly save the report page setup and Dissociate options,
- Do not use No Printer
Crystal Reports uses printer drivers to construct its design pane. Due to this printer dependency, when reports are deployed to other computers, the print and view may not be as expected. Understanding the concepts covered in this series of documents will help you achieve consistent printing and viewing output when deploying reports to different environments.
It is also highly recommended you review the Printer Doc’s in the link above to understand how and why CR uses Printers and how these are used in the SDK.
WHAT YOU NEED TO KNOW WHEN DESIGNING LABEL REPORTS:
First thing to consider is to use a real Label printer driver. The reason for this the RPT file now saves the printer name and Paper size. The formatting component will now look for the Printer name and the Paper size by name and then by ENUM.
Each paper size has a ENUM assigned to it, for more info look up these defaults as defined by Microsoft. 1 to 127 is the standard all devices use.
Depending on the Printer driver it can then use a unique ENUM for each label size it supports plus the ability to add multiple custom or User Defined paper sizes.
To get started first install the Label Printer driver onto each PC and Printer Server that your system will be used to access the label printers.
- Create a Unique Printer Name, and if possible assign it a unique ENUM, some drivers are not capable but it’s not required. Just be sure to use the same ENUM if the Driver supports it.
- Add the Custom Print Name and Custom paper size to each PC that has the printer installed.
- Set the default Paper Orientation as required, you can use multiple defines with various orientations and paper sizes. CR will fine the right one.
Once they have been installed and configured open or create your report and select the Printer in the Page Setup menu.
Note: I have selected a unique paper size.
The Dissociate option basically means “look for any paper of this size”
In this case it will only use the printer as selected.
If you now load this report in the Printer test app, link below, you will see this for paper size:
ENUM: 257 Name: S10cmX5cm
See Printing Crystal Reports – Using .NET SDK for details on the basic printer API’s and work flows.
If you wish to change it use PrintOutPutController() api as explained in the test app.
When a report is created the report will use the Users default printer driver installed on the development computer unless Page Setup is selected and the OK button is clicked. For more info how to design reports with nonspecific and specific printer requirements please see Printing Crystal Reports the Basics for more detail about this functionality.
Two new API’s I’ve added to the Viewers default print button is to use the default PrintToPrinter (P2P) or the enhanced PrintOutputController (POC) Methods. P2P is the default and is limited in what it is capable of doing. See below in the ViewReport() routine for more info.
More info on this product:
CR for VS no longer allows connecting to Business Objects Enterprise also known as Managed Reports. There is a separate .NET SDK for BOE 4.1 that eventually will have the above API’s but for now this is limited to CR for VS only. Although the Custom Paper size and using the ActiveX mode in BOE 4.1 .NET SDK should work.
Crystal Reports uses printer drivers to create the report design pane and to render the reports to screen, print and export. Printer drivers will affect the report behavior when the report is deployed to other computers and it is the report author’s responsibility to choose the correct report initial conditions.
Final Overview and what to expect:
We have spent hours defining and updating the logic and how Crystal Reports Designer and the .NET SDK deal with printers and orientation.
The Engine will now “look” for the design printer and if not found it will scan most of the printers and paper sizes for a “close match”, so if not defined you may find it did not select a printer and paper size that does not come close to what is actually required.
For any “odd behaviour” have a close look at the paper size CR did select, if the one you are trying to use does not “fit” the page you will get non-working results when printing the report so be careful on what you choose and how you save the report.
For best results always use a specific Label printer and either a default label size or one that you can install onto each Users PC and Printer server.
PS – One thing to note, Microsoft has that “Easy Print” which if enabled you will see a (redirect 2) behind the name. It’s not actually using the local printer and just streams the printer info down to the users PC. I don’t recommend and we don’t support that driver. Crystal Reports has always required a real printer be installed on the local work station and Application Server is using the SDK’s.
Related Blog Posts
Crystal 2008.Net runtime or Crystal Reports for Visual Studio 2010 .Net runtimeBy Former Member, Nov 01, 2016