Printing Crystal Reports – The Basics
Printing Crystal Reports is a series of documents that explain how Crystal Reports behaves when viewing, exporting and printing. The series is authored by Donald Williams and Ludek Uher, both Senior Support Engineers at AGS Product Support. The documents apply to Crystal Reports 2013 and SAP Crystal Reports, Developer Version for Visual Studio .NET only.
Crystal Reports uses printer drivers to construct it’d 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.
Basics – Before Designing a Report
Crystal Reports relies on printer drivers to render the report (view, export and print). Therefore the initial consideration is not Crystal Reports. Rather, it is the printer driver that will be used when the report is being designed and the printing requirement when the report is deployed to other systems. The printer driver defines the report design pane; paper size, paper orientation, paper name and page margins. Additionally the report queries the printer driver for each of the font elements (font metrics), such as average character height, character width, height of the ascenders and descenders etc. The screen shot below shows the default paper properties of the HP Universal PCL 6 (HP PCL 6) printer driver.
When a report is created the report will use the default printer driver installed on the development computer.
Deploying a report may involve sharing the report with another Crystal Reports designer, running the report in an application that uses one of the Crystal Reports Solution Development Kits, or running the reports in a SAP BusinessObjects BI Platform setting. Printer drivers used on deployed systems may
lead to output inconsistencies – when viewed, when exported and when printed.
Note: In this document, the term “printing” will typically encompass viewing, exporting and printing to a printer.
Inconsistencies due to printer drivers
Inconsistencies (viewing, exporting and printing) may occur if the printer driver on the deployed system is different than the printer driver used to create the report. These inconsistencies are a result of the various methods that individual printer drivers use to measure text metrics such as font size. When printed, text-based objects may be misaligned, truncated, overprint each other and so on. Examples of text-based objects include string or character fields, text objects, memo fields, numeric fields, and formula fields.
Problems such as these may arise when you have:
- Two identical printers, but each one is using a different printer driver.
- Two different printers using the same printer driver.
- Two different printers using different printer drivers.
- One printer driver that uses the TrueType font and a second printer driver that maps TrueType fonts to PostScript fonts.
- Two identical printers using the same printer driver, but each one is printing from a different version of Microsoft Windows.
- Two identical printers using the same printer driver, but the printer drivers are different versions.
- Two identical printers, two identical printer drivers, and two identical operating systems, but the resolution of the video drivers is different.
First step to resolving the above noted issues is to ensure that the installed printer driver is updated with the most recent patches and that it is designed for the Operating System.
It is the responsibility of the report author to design reports that accommodate printer driver dependencies and still print consistently using different printer drivers. To do this, Crystal Reports provides several design solutions. If taken into account when creating the report.
For reports that will be viewed online (Web applications or BI Platform viewer), you can avoid inconsistencies due to printer drivers by disabling the report's reliance on a printer driver. For more information on disabling a printer driver, see No Printer (optimize for screen).
The Crystal Reports Page Setup Dialog
This dialog box appears when you choose the Page Setup command from the File menu and for our example looks as in the following screen shot.
When the HP PCL 6 printer driver is set as the default printer driver, the report will use that printer’s information regarding paper size, paper name paper margins and more. Thus looking at the Page Setup dialog in the Crystal Reports designer, we see the following:
Note that the Document Size from the printer driver is the same as described in the Page Setup dialog; Letter (8.5’’ x 11’’). Also, the paper Margins information is retrieved from the HP PCL 6 printer driver. This is a critical piece of information as changing printer drivers may lead to, at minimum incorrect print out and at worst an apparent data loss. Using the above printer driver the report design pane will look as in the following screen shot:
Notice that the design pane is not 8.5’’ wide (Horizontal dimension). Rather it is 8.5’’ minus left + right margin. The same is the case for the paper length (Vertical dimension). The pane will be limited to 11’’ minus the top + bottom margin.
No Printer (optimize for screen)
When the “No Printer (optimize for screen viewing)” option is enabled, the report does not use a printer driver to render the report layout and display. To see the effect, consider a report that is based on an HP PCL 6 printer driver with page size of 8 ½ X 11 as default. When the “No Printer” option is enabled, the Page Setup dialog displays the following:
Note the difference. Originally, the paper name was Letter (8.5’’ x 11’’), now it is 8.5 x 11’’ (Letter). Additionally the paper size has changed from 8.501 to 8.500 Horizontal and 11.001 to 11.000 Vertical. The change is due to the report using its own internal “printer driver” which locates the closest paper dimensions and paper name to that defined by the default printer driver used to create the initial report design pane. The Crystal Reports available paper size design conditions in this case can be seen in the Page Setup dialog:
All of the paper sizes visible in the Page Setup dialog when the “No Printer” option is enabled are defined internally in the report engine and not by any printer driver. The option should be selected to format reports for web viewing as different printer drivers may render the report objects into different sizes, positions and so on. When the option is selected the report will not get associated with any printer. The report engine will format the report using the settings from the report or the settings provided from the code (if using one of the Crystal reports Solution Developer Kits). Use the “No Printer” option for reports that will be printed from web applications and from SAP BusinessObjects BI Platform (Business Objects Enterprise). Unless(!), the report must use a very particular and specific printer driver. An example may be a label printer.
NOTE: With the "No Printer" option enabled, exporting to any format, the selected paper size will not be maintained. The paper size will default to 8 1/2 X 11 inch paper size. To maintain selected paper size, the "No Printer" option must not be enabled.
Dissociate Formatting Page Size and Printer Paper Size
For this option, we first need to understand what the option is actually trying to say. What is “Formatting Page Size” and what is “Printer Paper Size”?
Formatting Page Size is the page size as remembered by the report, but it is based on the size of the paper as defined by the printer driver. Printer Paper Size is the size of the paper as defined on the printer driver. When a report is initially designed, “Formatting Page Size” and “Printer Paper Size” are identical. There are a number of instances when this option needs to be considered;
- Creating a custom size (user defined paper size) report within the Crystal Reports Designer. This would usually apply to labels, but not exclusively.
- The report will be used to print on 8 ½ X 11 as well as A4 paper size.
- When creating reports for label printers. Labels will often be defined as custom paper size.
- View a report as one long page (used for web viewing).
- Viewing a report that is wider than paper size defined by a printer driver. This could be a 100 column report whose total width will span tens of inches. A typical printer driver will not be able to print any document with a width of tens of inches.
Note that the report engine will scale the report to fit on the paper it is requested to print on. This may result in smaller font being used. Margins may also be altered to conform to the scaling.
Page Margins are also based on the paper size as defined on the printer driver. In the Page Setup dialog, these can be modified and saved into the report, thus over-riding the printer paper margins – if supported by the printer driver. Note that when Crystal Reports sees a paper margin on the printer driver that is set to zero, the margin will be adjusted to 0.25 inches. If you want a zero margin maintained, you must set it in the Page Setup dialog.
When enabled, this option takes effect if a new page size is selected. If the page size is large enough for the current printable area, Crystal Reports will increase or decrease the margins by enlarging or reducing the left/right and top/bottom margins by the same factor. If the new page size is smaller than the current printable area, Crystal Reports fills the entire page by reducing the margins to 0. Note that if a larger page is set after a smaller page size is set, the printable area will be kept and the left/right, top/bottom margin ratios will be 1:1.
Margin Conditional Formula
The Conditional Formula allows you to control page margins on a set condition. For example a conditional formula could check for odd and even page number. If page number is odd, the page margin could be set to one inch, else two inches. For more details see the Crystal Reports Help file.
Report Initial Print Condition
We can finally look at how the report engine constructs and uses the design pane. We can also start to understand why a choice of printer driver may become one of the most important considerations in report design. When a report is created (File | New Report):
The report engine uses the default printer driver to build the design pane. However, the printer driver and its default page information is not saved into the report. Rather, the report engine looks for the closest matching paper information in its internal list and uses that information (see Fig. 5).
Printing Free Flow Document vs. Object Layout Document
Crystal Reports is an object layout oriented application as opposed to free flow design in applications such as Microsoft Word. A free flow document designed on an 8 ½ X 11 inch paper size, printed on an A4 paper (8.27 X 11.69 inches) will automatically adjust for the paper difference:
The above example demonstrates the horizontal difference only, but similar differences would occur in the vertical dimension. The same text placed in a text object in Crystal Reports will look as follows:
Note that the last two words (“how to”) on the second line is cut to “hov”. This is because Crystal Reports cannot flow adjust to the smaller horizontal dimension of the A4 paper size.
It is interesting to see that in report design view, the whole text object is visible, but part of the object is rendered off screen or off paper and thus the reason why part of line two is cut off:
Different printer drivers may cause similar issues even if they use 8 ½ X 11 inch paper as they may define different default paper margins.
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.