Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture...

24
Crystal Reports Printer Driver Dependency: How to Design Reports that Print Consistently in Different PC Environments Overview This document addresses the issue of reports printing inconsistently on different machines and explains why Microsoft Windows programs are dependent upon printer drivers when printing documents. Discussion focuses on exactly how Crystal Reports handles the formatting, placement and printing of the many objects that exist in reports. With this knowledge, developers and other Crystal Reports users who print on multiple platforms will be better equipped to design reports that will accommodate printer driver dependency and print consistently across multiple environments. Workable solutions, tips and tricks, and design criteria are provided. Contents HOW WINDOWS PROGRAMS USE PRINTER DRIVERS....................................... 3 AN EXERCISE IN PRINTER DRIVER DEPENDENCY ............................................ 4 HOW PRINTER DRIVER DEPENDENCY AFFECTS DISTRIBUTED REPORTS ........... 5 Text-based objects ........................................................................................... 6 OLE objects ...................................................................................................... 6 Combining text-based and OLE objects ....................................................... 6 CHARACTERISTICS OF OBJECTS IN CRYSTAL REPORTS................................. 7 Individual text-based objects and truncated text ......................................... 7 Suggested workarounds ............................................................................... 9 Memo fields and multi-line text objects ..................................................... 10 CHARACTERISTICS OF REPORT SECTIONS IN CRYSTAL REPORTS................. 11 How Crystal Reports controls the placement of objects ............................. 12 Introduction of Free Form Placement ........................................................ 13 Free Form Placement of objects selected.................................................... 15 Using grids and guidelines .......................................................................... 16 DESIGN CONSIDERATIONS WHEN SHARING REPORTS ................................... 19 Correctly spacing text objects ...................................................................... 19 Placing text objects close to other objects................................................... 19 Placing multi-line text objects...................................................................... 19 Using TrueType fonts ................................................................................... 20 6/13/2007 12:07 PM Copyright © 2006 Business Objects. All rights reserved. Page 1

Transcript of Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture...

Page 1: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports

Printer Driver Dependency: How to Design Reports that Print Consistently in Different PC Environments

Overview This document addresses the issue of reports printing inconsistently on different machines and explains why Microsoft Windows programs are dependent upon printer drivers when printing documents. Discussion focuses on exactly how Crystal Reports handles the formatting, placement and printing of the many objects that exist in reports. With this knowledge, developers and other Crystal Reports users who print on multiple platforms will be better equipped to design reports that will accommodate printer driver dependency and print consistently across multiple environments.

Workable solutions, tips and tricks, and design criteria are provided.

Contents HOW WINDOWS PROGRAMS USE PRINTER DRIVERS.......................................3 AN EXERCISE IN PRINTER DRIVER DEPENDENCY ............................................4 HOW PRINTER DRIVER DEPENDENCY AFFECTS DISTRIBUTED REPORTS ...........5

Text-based objects ........................................................................................... 6 OLE objects ...................................................................................................... 6 Combining text-based and OLE objects....................................................... 6

CHARACTERISTICS OF OBJECTS IN CRYSTAL REPORTS.................................7 Individual text-based objects and truncated text .........................................7 Suggested workarounds ...............................................................................9 Memo fields and multi-line text objects.....................................................10

CHARACTERISTICS OF REPORT SECTIONS IN CRYSTAL REPORTS.................11 How Crystal Reports controls the placement of objects.............................12

Introduction of Free Form Placement ........................................................ 13 Free Form Placement of objects selected.................................................... 15 Using grids and guidelines.......................................................................... 16

DESIGN CONSIDERATIONS WHEN SHARING REPORTS...................................19 Correctly spacing text objects...................................................................... 19 Placing text objects close to other objects................................................... 19 Placing multi-line text objects...................................................................... 19 Using TrueType fonts................................................................................... 20

6/13/2007 12:07 PM Copyright © 2006 Business Objects. All rights reserved. Page 1

Page 2: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

Using the most common video resolution................................................. 20 Setting specific margins ............................................................................... 20 Changing the paper orientation .................................................................. 20 Choosing the default printer (Crystal Reports 10 and lower)................. 21 Maintaining default printer settings (Crystal Reports 10 and lower) .... 22 Selecting Free Form Placement for all sections ......................................... 22

REPORT CREATION CHECKLIST TO SHARE REPORTS WITH OTHERS...............22 TIPS AND TRICKS.......................................................................................23

Duplex printing in Crystal Reports ............................................................ 23 Printing subreports in different formats .................................................... 23 Printing is slow when using a dot matrix printer..................................... 23

FINDING MORE INFORMATION .....................................................................24

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 2

cr_printer_dependency.pdf

Page 3: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

How Windows programs use printer drivers All Microsoft Windows programs require the printer driver to paginate a document. Printer drivers measure font information, based on the particular font selected (Courier, Times New Roman, Arial, and so on), and the font’s point size. The driver applies values (in pixels) to each of the font elements such as the average character height, character width, height of the ascenders and descenders, internal leading, external leading, and maximum character width to name a few. True type fonts can be sized to any height that is accepted by the printer driver. True Type fonts are WYSIWYG (what you see is what you get) type fonts. This means that they can be printed exactly as they appear on the screen. For more information on True Type fonts, search the Windows online help.

When a particular font is selected, the Windows program executes a GetTextMetrics API call that queries the printer driver. The printer driver returns the TextMetric structure that contains the elements mentioned above and their assigned values. A structure exists for all fonts and all point sizes of a specific font. Now that the Windows application has all of the font information, it can assemble or paginate the document.

An inconsistency exists because different printer drivers measure the same font differently. For example, if a TrueType font is realized (measured) on two printers that use the same printer driver, and installed on the same version of Windows, the two fonts should have identical text metrics (the values, in pixels, of each of font elements should be the same). Problems could arise when you have:

• Two identical printers, but each one is using a different printer driver. Many printers can be driven using several different print drivers.

• Two different printers using the same printer driver. Some drivers can be used to drive several different printers.

• Two different printers using different printer drivers.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 3

cr_printer_dependency.pdf

Page 4: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

• One printer driver that uses the TrueType font while the other maps the TrueType font to a PostScript font (e.g. LaserJet in PCL mode versus LaserJet in Postscript mode).

• Two identical printers using the same printer drivers but each one is printing from a different version of Windows.

• Two identical printers where each printer is using the same printer driver, such as Hppcl5ms.drv, but the printer drivers are different versions.

• Two identical printers, two identical printer drivers, and two identical operating systems; however, the resolutions of the video drivers are different.

For example, a document using one printer driver may require six full lines to display a block of text; however, another printer driver that measures fonts narrower could result in the same block of text requiring less than six full lines. A third printer driver that measures fonts wider could require six full lines plus a seventh line to display the last one or two words.

An exercise in printer driver dependency To see an example of printer driver dependency, create a few documents using:

• a word processor such as Microsoft Word or WordPerfect

• a spreadsheet application such as Microsoft Excel

• your report writer, Crystal Reports

• and/or other applications that you have installed

1. Design these documents using your current printer set as the default printer. The information in these documents should completely fill the page and print right up to the margins.

2. Print and close the documents. Make a note of where the pages break and individual lines wrap the text.

3. Set up another printer and set it as the default printer. You do not need to have the actual physical printer present to set one up. If you do not have a second physical printer, you will only be able to view the examples on screen and compare them to your printed examples. If you can, make sure that the actual printer driver used by the second printer is different. Many printer drivers are universal drivers and are used to drive a number of different printers.

4. Open each of the three documents again and preview them without making any modifications to them. If you have access to two very different printers, take the opportunity to print the examples and compare them. Printing to a postscript printer using a postscript and a non-postscript driver will also yield similar results.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 4

cr_printer_dependency.pdf

Page 5: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

You will notice that while no information is lost, line breaks, width of the fonts, inter-line spacing, inter-character spacing, and page breaks, etc, will all be different. Depending on the drivers you choose for this exercise, the difference between the two sets of documents will vary from no difference at all to significant reformatting occurring.

The results of the above exercise will occur using all versions of Windows. Different programs and different drivers will illustrate varying degrees of difference. Also, the same printer driver used in a different version of Windows will yield different results.

For instance, if the first line of a document ends with “Crystal Reports (CR) printing”, when the printer is changed to another printer (the names of the printers are not important), the same first line now ends with “(CR)”. Meanwhile “printing” is forced to print on the beginning of the second line because the printer driver measures the same font slightly wider.

As another example, instead of changing the printer driver for the second set of documents, simply change the video resolution. You will also notice differences. The important point to note is that different hardware and software environments interpret and print the same documents differently.

How printer driver dependency affects distributed reports For many users, printer driver dependency is not an issue. Most users do not incorporate widespread sharing of their electronic documents (as opposed to printed documents). For others, distribution may only entail inter-office sharing, where the printers, printer drivers and operating systems (PC environments) are identical. However, many other users of Crystal Reports create reports for widespread distribution, either as standalone-compiled reports or as part of a developed application, and they do not have control over their customers’ printing environment.

One of the most fundamental differences between distributing a Crystal Reports report and, for example, a word processing document, is that in order for the user to view a word processing document they must own the application that created it, or another application that can import and read it. In either case, if the document has been reformatted because a different printer driver is being used, the new user has the program and, therefore, the ability to edit the document and return it to its original format. This usually involves actions such as changing the font size and/or adjusting page margins.

Conversely, a developer’s customers are not necessarily required to own Crystal Reports in order to view their reports. This functionality means

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 5

cr_printer_dependency.pdf

Page 6: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

that their customers may not have the editing capabilities necessary to make minor changes to their reports.

Since printer driver dependency cannot be avoided, the goal of the report distributor is to design reports that accommodate dependency and still print consistently using different printer drivers. To do this, there are three main concerns that developers and distributors must consider when designing reports.

Text-based objects The first concern is the effect that using different printer drivers can have on both the printing of text-based objects that make up a report and how these objects are positioned on a page.

A text-based object in Crystal Reports is defined as any object that contains alphanumeric text. Examples of text-based objects include String or Character fields; text objects (which contain text that you type and can also contain Memo fields and other String or Character fields); Memo fields; Numeric fields and Formula fields.

For example, a text-based object references a printer driver that measures fonts differently than the driver that was used when the report was created. Because the report designer did not take the necessary steps to accommodate printer driver dependency, the printed report could include:

• Columns of data no longer aligned.

• Inconsistent spacing.

• Truncated text.

OLE objects If an object in a report is not a text-based object, then it is an OLE object. Examples of these include bitmapped images, graphs, lines, and boxes and cross tab objects. While text-based objects have a strong dependency on the printer driver and are thus sensitive to the printer driver changing, OLE objects do not share the same dependency and will print consistently even though the printer driver changes.

Combining text-based and OLE objects The third concern relates to how both the text-based and OLE objects that make up a report print relative to each other. This will sometimes create conditions such as lines and boxes printing out of place, objects printing over other objects on the same line and reports no longer matching preprinted forms.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 6

cr_printer_dependency.pdf

Page 7: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

Crystal Reports architecture

The Crystal Reports architecture offers the ability to print consistent-looking reports in different environments. What is needed is an understanding of how different objects are treated and how they react, depending on the report section they are placed in and the formatting that is applied to them.

The following sections, Characteristics of objects in Crystal Reports and Characteristics of report sections in Crystal Reports, illustrate how report objects and sections behave. The section Design considerations when sharing reports presents a methodology for designing sophisticated and consistent-looking reports.

NOTE If you are printing a report using the same printer configuration that was used when the report was designed, then it does not matter how you design your report. All the elements of the report will print correctly and consistently. Design considerations must only be taken into account when the report must print from different versions of Windows and/or using different printer drivers.

Characteristics of objects in Crystal Reports

Individual text-based objects and truncated text A text-based object in Crystal Reports is defined as any object that contains alphanumeric text such as String or Character fields; text objects (which contain text that you type and could also contain Memo fields and other String or Character fields); Memo fields; Numeric fields, and Formula fields. As explained earlier, different printer drivers measure font metrics differently.

When a text-based object is placed on the report, the object has specific boundaries. The height of the object’s boundaries is always determined by Crystal Reports but is based on the height of the font. The height of the font is determined by the printer driver (GetTextMetrics API call) based on the font and font size selected. The width, however, is determined differently depending on the nature of the text-based object being worked with.

For database fields that are not Memo fields, the width is initially determined by the width of the field, as defined in the database, and the average character width as provided by the font and font size selected (GetTextMetrics API call).

For example, you have a database field called {Customer.LastName} and your database defines this field as a text field with a length of 35 characters. When you place this field on your report, the width of the boundary will be 35 times the average character width of the font and font size that the text-based database field is formatted to. Suppose that the field was populated with 35 lower case letter “e”s (which are slightly

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 7

cr_printer_dependency.pdf

Page 8: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

narrower than the average character width), the boundary would be wide enough to accommodate the entire record (35 “e”s) and an additional three more letter “e”s. However, if the field was populated with 35 lower case “w”s (which are wider than the average character width), the boundary would only be wide enough to display 28 “w”s and the remaining seven would be truncated or cut off.

So, why wouldn’t a field’s default size always be wide enough to accommodate the widest possible string of text? The example below shows that while the default field width is not wide enough to show all of the “w”s, the text box at the top, which is the same font, font size and width as the text-based database fields below it, contains 49 characters and not 35. Remember that this is the initial default boundary width. The width can always be resized to increase or decrease the width as you see fit.

On the Insert menu, when you click Text Object, you are presented with an empty text object in edit mode. The default width of this text-based object is approximately 17 average character widths wide. Text objects are different in that their width will automatically expand as you enter in text and/or database fields. As with all other text-based objects, you can resize the width.

The various Number fields, such as Double, Single, Integer, Long Integer and Byte all have different default widths. Once again, as with all other text-based objects, you can resize the width. Whether the default widths are accepted or the text-based objects are resized, a problem could arise if the text inside prints right to the edge of the text-based object’s boundary. The report may look fine on the machine it was designed on. However, if the report is printed using another printer driver that measures the font wider, the length of the text grows but the object’s boundaries remain fixed. This results in the text being truncated or cut off.

This fact cannot be changed. While you may think that the objects should be designed to expand automatically as needed, this is not a workable solution. The reason for this is that the width of the report is finite, as defined by the paper width and the margins. If objects were allowed to expand as needed, then they could expand enough to fall outside of the

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 8

cr_printer_dependency.pdf

Page 9: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

left and/or right margins. Also, if you had two objects printing side by side, what would happen if the object on the left were to expand automatically? Should it overprint the object on the right or should it push it over?

Overprinting is not a solution. If the objects were allowed to push each other over, what should happen if the boundary of a text-based object on line one of the report is not wide enough and needs to be expanded but on line two it is wide enough and does not need to change? Or, what if the text-based object on the left is left aligned (the text will expand to the right) and the object on the right is right aligned (thus, the text will expand to the left)? Which object should get pushed over? Objects expanding automatically could also place columns of data out of alignment or out of place in the case of preprinted forms. There are so many possible scenarios that it would be impossible to control object growth by adding additional “growth” options. If you completed the exercise at the beginning of this document, you have already experienced the problems that word processors and spreadsheet applications encounter.

Other Crystal Reports users have suggested that the font size be automatically reduced so that the text will still fit into the established space. This is not an alternative because the Crystal Reports application is not able to determine whether the report requires that the fonts must only be one particular size, such as on many government reports and forms that are used for scanning. In cases where all of the fonts were originally the same point size, some of these fonts might now be a point size smaller, resulting in a less than professional look to the report.

Suggested workarounds The numerous inconsistencies of different printer drivers can only be accommodated to a certain extent. There are two ways to do this:

• If you format the text-based object to print on multiple lines (click Format > Format Field > Common tab and select the Can Grow option) and the text prints wider than the object, the text will wrap onto additional lines. This is not an effective solution for strings of text that do not have spaces in them, such as single words, because although the line will wrap, the text string will break at the boundary and then wrap. This functionality exists in many programs. Below is an exaggerated example:

Printer driver on development PC:

Printer driver on client’s PC that measures fonts wider:

Printer driver dependency Dependency

Printer driver Dependency

Dependency

• If adding additional lines to an object is not feasible, an alternative is to expand the boundary of the object so that it is a little wider than the widest block of text that the object will contain. There are many

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 9

cr_printer_dependency.pdf

Page 10: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

instances where the actual text in a database field is far less than the field is formatted to be.

For example, a {Table.LastName} field is designed with a field size of 80 and the longest name in the database is 28 characters. When the field is first placed into the report the field will be 80 times the average character width, which is wider than necessary. However, if you reduce the width of the field, do not reduce it so much that it is just barely long enough to accommodate the longest string of text. Instead, it is suggested that you make the field a little wider. Below is an exaggerated example

The original default width established by Crystal Reports. In this case, it is 80 times the

average character width.

In the example on the left, the field width

has been reduced so that it is just wide enough to print the longest field. In the

example on the right, the field boundary has been manually expanded to

accommodate the potential growth of the longest field.

It is generally recommended that the field width be increased by about 5%.

NOTE The effect of a wider font width will be more noticeable on a long String field, such as a product description, than on a small String field such as a 6-digit product code.

Memo fields and multi-line text objects While text-based objects that are formatted to print on multiple lines follow the same design rules as other objects, they have an additional characteristic that must be considered. If the printer driver expands or contracts the spacing of the text, a text-based object formatted to print on multiple lines (click Format > Format Field > Common tab and select the Can Grow option) will not get its contents truncated. However, word wrapping could be different and in some cases the number of lines necessary to print the object may differ from the number required when the report was first designed.

If you did the exercise suggested at the beginning of this document, you will see the effect that a printer driver has on a Memo field. Take a look at your word processing samples for examples of how word wrapping can be affected. Unlike single line text-based objects, expanding the boundary width of the text-based object that will print on multiple lines to accommodate possible growth is not a viable option because the line width will just increase to the expanded boundaries. Since making the text-based object wider is not an option, the possibility that it will require less, the same, or more lines on different machines will have to be accommodated in the report design.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 10

cr_printer_dependency.pdf

Page 11: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

This is how a text-based object will print when formatted to print on multiple lines. Notice the number of lines the object requires when the printer driver measures the character spacing differently.

This is how a text-based object will print when formatted to print on multiple lines. Notice the number of lines the object requires when the printer driver measures the character spacing differently.

This is how a text-based object will print when formatted to print on multiple lines. Notice the number of lines the object requires when the printer driver measures the character spacing differently.

The text-based object on the right is the same as on the left except that its width

has been expanded.

Notice that the text in the object simply expands to the new width.

The text-based object on the right is the same width as the text-based

object above and to the left. Printed with the font measuring slightly wider,

line wrapping is affected and an additional line is required to print the

same string of text (exaggerated example).

This is how a text based object will print when formatted to print on multiple lines. Notice the number of lines the object requires when the printer driver measures the character spacing differently.

Techniques on managing the characteristics of multi-line text-based objects within a report will be included in the discussion of how the individual objects and sections work together.

In some cases, if selecting a particular font size, word wrapping does not work. This could be because the printer driver does not understand that type of functionality.

Characteristics of report sections in Crystal Reports In all versions of Crystal Reports, a report consists of several sections such as the Page Header, Group Header, Details, Group Footer and Page Footer. In versions of Crystal Reports prior to version 5.0, all sections consist of complete lines; complete in that a section will never consist of a half line (for example, four lines and never four and a half).

In a new report, each section consists of at least one line. The default fonts for Fields and Text Objects determine the line’s height:

1. On the File menu, click Options.

2. Click the Fonts tab. You will see command buttons labeled Fields, Summary Fields, Group Name Fields, Text Objects and Field Titles.

When a text-based object is placed on a line, the line’s height is adjusted up or down so that the line is now high enough to accommodate that text-based object. If another text-based object is placed on the same line and its font size is larger than the first, the line’s height is again adjusted to accommodate the second text-based object. Thus, the text-based object determines a line’s height with largest font on the line. All text-based

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 11

cr_printer_dependency.pdf

Page 12: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

objects are positioned on a line so that their base lines will all line up on any given line. This means that a text-based object cannot be placed between lines; it must be placed on a line. Consequently, in versions of Crystal Reports prior to version 5.0, all text-based objects are bound to lines.

The screen shots above are from Crystal Reports version 8.5. The image on the left shows the Detail section with no objects inserted and a default line height of 12 points. When a database field is first placed on the report (center image), the line’s height does not change because it is the default line height (12 points). If the text-based object’s font size is increased from 12 to 16 points, the actual height of the object (boundary) increases.

If the line height increases to accommodate the larger text-based object, then the base lines of the two dissimilar font sizes will print on different lines. This is seen in the image on the right. If a second text-based object is placed on the same line as the larger 12-point object and the smaller font object’s height (boundary) matches that of the larger font, the baselines of the two dissimilar font sizes will match, thus printing on the same line.

As other text-based objects are added to the report, either by adding lines to the same section or by placing them in other sections, the vertical spacing or interline spacing, while controlled by Crystal Reports, is determined by the printer driver. Remember, the text metrics of a font determine interline spacing. This functionality makes it difficult to create reports designed to print on preprinted forms if the printer driver is going to change. For example, totals that used to print in the middle of a box might now print below the box because the new printer driver applies a greater value to interline spacing. Line by line, the text in the report will move down farther than when the report was first created.

How Crystal Reports controls the placement of objects In Crystal Reports, each section’s upper left corner is given the X and Y coordinates of (0,0). Crystal Reports controls the placement of ALL objects (text-based and OLE objects) within each section by applying an X and Y coordinate to the upper left-hand corner of its boundary. The values are measured and stored as absolute coordinates in twips. A twip

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 12

cr_printer_dependency.pdf

Page 13: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

is 1/1440th of an inch or a twentieth of a point. A point is 1/72nd of an inch and is used to measure the height of characters. Thus, if the upper left corner of an object’s boundary is 0.5 inches to the right and 0.3 inches down from the top left hand corner of the Details section, the (X, Y) coordinates of that object are (720,432). When it is time to evaluate and print the Details section, Crystal Reports will know where to start printing the object by referencing these X and Y coordinates.

Introduction of Free Form Placement

NOTE In Crystal Reports XI Release 2, it is no longer possible to switch to a Non-Free Form Placement mode, as we can achieve the same functionality using the snap to grid option (see the Using grids and guidelines section for more details).

Up to version XI Release 1, Crystal Reports offers a choice of how vertical placement of objects is to be determined:

In versions 5, 6, 7, 8 and 8.5:

1. On the Format menu, click Section.

2. In the Section Expert dialog, the Free Form Placement check box (upper right) can be selected or cleared.

In versions 9, 10, and XI Release 1:

1. On the Report menu, click Section Expert.

2. In the Section Expert dialog, the Free Form Placement check box (upper right) can be selected or cleared.

This setting will determine how Crystal Reports references the (X, Y) coordinates to position and begin printing the objects.

If a section is formatted with Free Form Placement cleared, text-based objects are once again bound to lines and the functionality closely resembles that of previous versions of CR. The section will be divided into lines with each line being indicated by a horizontal guideline. As you make the section bigger, you increase its size in increments of complete lines and never by fractions of a line. This can be seen by the addition of new guidelines. Initially, the line height (guideline spacing) for newly created lines is determined by CR; however, it is based on the height of the default font sizes, as established in the File Options dialog box described earlier.

Remember, values for the height of fonts and interline spacing are provided by the printer driver. If you place a text-based object on a line and increase or decrease its font size, the line’s height will change to

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 13

cr_printer_dependency.pdf

Page 14: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

accommodate the new font size. The positions of all of the guidelines within the section are then automatically adjusted up, or down, as each line’s height changes.

For example, a Details section has two columns of text-based objects vertically aligned:

As you can see in this example, the largest font on the line determines the line height.

Note that the base line of the font, and not the bottom of the text-based object itself, is

attached to the guideline.

Also note the height of text-based object boundaries of the smaller fonts when placed

on the same line as a larger font. Unlike previous versions, the height does not

increase to match the height of the larger font.

When Free Form Placement is cleared, Crystal Reports no longer references the object’s absolute coordinates to determine where it prints. Instead, only the absolute X coordinate is referenced to determine where each object begins printing horizontally (left/right placement). The Y coordinate is still referenced for vertical placement of the object but the coordinates may be adjusted by Crystal Reports when the printer driver changes. When using a different printer driver that measures interline spacing greater than the driver originally used to create the report, the Y coordinate will be increased and the text-based object will be placed and printed farther down the page. In this manner, the printer driver maintains line spacing. For all intensive purposes, the printer driver is determining the vertical placement of text-based objects much like previous versions of Crystal Reports (prior to version 5).

By contrast, the placement of OLE objects such as graphics, boxes and lines is not controlled by the printer driver and is not confined to specific lines (again, as for CR prior to version 5). Thus, Crystal Reports will always reference the object’s absolute coordinates to position and print the OLE object.

For example, when designing a report, a box (OLE object) is placed around a database String field (text-based object). Everything appears to be aligned correctly. The report is printed, using a printer driver that measures interline spacing greater than the original printer driver. The placement of the box does not change relative to the section in which it is inserted (the X and Y coordinates do not change). However, the vertical placement of the text-based object does change because the Y coordinate is adjusted upwards, based on the printer driver being used. Remember, this value is a measurement from the section’s upper left corner. The greater the value, the farther down the page the object will print. This is why clients may complain that the positioning of lines and boxes on their reports is incorrect and that a dividing line, for example, is printing over top of the last line of text instead of underneath.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 14

cr_printer_dependency.pdf

Page 15: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

If you are distributing reports containing sections formatted with Free Form Placement cleared and you need to insert lines and boxes or other OLE objects, format the object’s border properties rather than inserting lines and boxes independently:

1. Right-click on the object, and then select Change Border from the shortcut menu. The Format Editor appears.

2. Select the formatting options you require. Click OK.

If your report requires OLE objects such as graphs, boxes, lines and bitmapped images such as company logos, it is best to have each section formatted with Free Form Placement selected. Not doing so will increase printer driver dependency and could create inconsistent reports. The advantages of having every section formatted with Free Form Placement selected will be discussed in the next section.

Remember that every section can be formatted with Free Form Placement selected or cleared. It is highly recommended that every section in your report be formatted in the same manner. Do not have some sections formatted with the Free Form Placement selected and others cleared.

Free Form Placement of objects selected In previous versions of Crystal Reports, only OLE objects (lines, boxes, bitmapped images, graphs, etc) could be placed anywhere in the section. Text-based objects had to be placed on specific lines and could never be placed between two lines.

When a section is formatted with Free Form Placement selected, all objects can be placed anywhere in a section. With Free Form Placement selected, it is possible to have two smaller text-based objects placed beside one larger text-based object.

Note that there are no guidelines to indicate specific lines.

Crystal Reports places all objects within a section based on their absolute coordinates. This means that the printer driver no longer controls the vertical placement of text-based objects. In the example above, the report designer places Field 1 and Field 2 on the report. X and Y coordinates that tell Crystal Reports where to place and print the objects have been

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 15

cr_printer_dependency.pdf

Page 16: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

applied to the objects. The distance between the baseline of Field 1 and the baseline of Field 2 is in twips (a twip is 1/1440th of an inch) and there is a measurable distance or space between the two text-based objects.

If the report is then printed referencing a printer driver that measures the same font higher, Field 1and Field 2 will still be placed and printed starting at the same coordinates within the section. Thus, if the starting points are the same but the font is higher, the space between the two text-based objects will be reduced.

While the printer driver no longer controls multi-line spacing of text-based objects within the sections, it still determines horizontal spacing of text within the text-based objects and interline spacing of multi-line text objects. In the above example, Field 3 is a memo field that will require approximately five lines to print. As with Fields 1and 2, the placement and starting point will be determined by Crystal Reports but the interline and character spacing of these five lines will be determined by the printer driver.

Using grids and guidelines Each section of a report contains a design grid. The grid always exists; however, Crystal Reports allows you to determine if the grid is visible or not and allows you to establish a grid size (how far each increment is apart).

1. On the File menu, select Options.

2. The Grid Options is located under the Layout tab.

The check boxes allow you to show the grid in Design and/or Preview mode. You can also set the grid size.

For example, setting the grid size to .167 will give you six grid lines per inch. The grid size is the same for all sections. The grid is measured from the upper left-hand corner of each section and continues down, and to the right, until the end of the section. A new grid of the same size then begins from the upper left-hand corner of the next section. This continues throughout the entire report.

The Options dialog box also gives you the option of selecting or clearing Snap to Grid. When you select Snap to Grid, the upper left corner of all newly placed text-based and OLE objects’ boundaries will snap to each grid point. Objects placed before selecting Snap to Grid will not move to snap to the nearest grid point. They will remain where they are. If you resize an object, the side(s) that you are resizing snap to the closest grid point. If you have several text objects of different font sizes snapped to the same vertical grid point, the base of the text will not line up because it is the object’s upper left corner that snaps to the grid. The height of the text object and the distance from the top border to the text’s baseline is determined by the size of the font.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 16

cr_printer_dependency.pdf

Page 17: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

In the example below, Free Form Placement and Snap to Grid are both selected.

CUSTNUM This field is placed on the report and then the font size is increased. Notice that the upper left boundary (indicated by the corner crop marking) is snaps to the grid point while the other three corners are not. The text-based object increases in size to accommodate the new font size.

CONAME This field is placed on the report and then the right border is moved. Notice that both the left and right boundaries are now snapped to a grid point.

STATE This field is inserted and then the bottom boundary is dragged down. Notice that the bottom boundary also snaps to the grid line but the font size does not change.

CITY This field is simply placed on the report. The boundary’s upper left corner snaps to a grid point.

COUNTRY This field is placed on the report when Snap to Grid is not selected. Notice that the object does not move and its boundaries do not snap to any grid point.

Notice that while the CUSTNUM, CONAME and STATE fields are snapped to the same horizontal grid line, the bases of the three fonts do not line up.

Also notice the grid in the top section with the five fields. The section consists of three full grid lines and a partial fourth. Even though the fourth grid line is not visible, the section below starts with a new grid with the sections upper left corner as (0,0).

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 17

cr_printer_dependency.pdf

Page 18: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

Guidelines are used to help you line up objects. They have a snap property that automatically snaps objects to them. That is, objects will connect to the guidelines as positioning devices. An OLE object can snap to a horizontal guideline on its top, bottom, or horizontal midline (the invisible line that bisects the object horizontally). However, the snap property of guidelines is different for text-based objects. When a text-based object snaps to a guideline, it is the baseline of the text and not the boundary of the object that snaps to the guideline. You can see a red tick in the left and right object border where the baseline is. Thus, if you need to place several text objects of different font sizes on one line and have their baselines line up, you will want to snap them to a guideline.

If you have selected Snap to Grid and you want to position text objects of different font sizes so that their baselines line up:

1. First insert a guideline. The guideline will snap to the grid line when it is placed.

2. Snap the text-based objects to the guideline.

NOTE When placing text-based objects, snapping to a guideline takes precedence over snapping to a grid line. However, if you later resize the text object’s height, the text object will snap the boundary being resized to the closest grid line.

In the example above, when CONTACTLN is first inserted, its baseline snaps to the guideline. When the upper border is then resized by dragging the object’s upper border upwards, the object assumes the characteristics of Snap to Grid. When PHONE is first inserted, its baseline also snaps to the guideline. However, when it is resized by dragging the bottom boundary downward, the object expands but the precedence of the text snapping to the guideline, instead of the grid line, is maintained.

Becoming familiar with the properties and functionality of grid lines and guidelines and working with the two requires some experimentation. It is important to note that selecting/clearing Snap to Grid and/or using guidelines or not, is a matter of selecting the best methodology for positioning the objects in your report exactly where you want them to be. Also remember that if you have Free Form Placement cleared (binding the section to lines) and you select Snap to Grid, all objects will snap to the guidelines for vertical placement and the left boundary will snap to both vertical guidelines and grid points.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 18

cr_printer_dependency.pdf

Page 19: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

Design considerations when sharing reports Listed below are several design hints for creating reports that will be shared with other people.

Correctly spacing text objects Ensure each field object is a little bit larger than the maximum value it will displayed. This will avoid values being truncated.

Placing text objects close to other objects As previously discussed, a text object’s boundary will not expand at runtime. If the printer driver being used prints fonts wider, the text could be truncated. A solution is to expand the width of the text-based object to accommodate this possible growth. While this is an effective solution, it does require some design considerations when placing text-based objects close to other objects.

Consider the following example:

A second object is placed to the immediate right of a text object. In order to accommodate possible growth, the text object on the left is expanded so that its expanded boundary is now overlapping the boundary of the second object. The report is printed and everything looks correct. It is then printed using another printer driver that causes the text to print wider. Although the first object’s boundary was made wider to accommodate the variance in text width, the two objects’ physical starting points (their X coordinates) do not change. Thus, a situation could exist where the text from the object on the left could print over top of the second object on the right. The same situation could exist when creating a columnar type report, where lines separate the columns. In this situation, the text could potentially print on top of, and outside of, the lines.

It is generally advisable to avoid designing distributed reports where the space between objects is very tight. Leave room for expandability and expand the text objects’ width by approximately 5%. An alternative is to consider reducing the size of the font.

Placing multi-line text objects Consider where and how you place multi-line text-based objects. You could encounter problems if you have other objects in the same section placed directly below an object formatted to print on multiple lines. For example, on the development PC, a multi-line text-based object is placed on the first line of a section. Since the text object normally never requires more than three lines to print, the developer places another object on line four of the section. Since a different printer driver could measure the font wider and cause the multi-line object to require an additional line, the object on the fourth line is now in danger of being over printed with the last line of the multi-line text object.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 19

cr_printer_dependency.pdf

Page 20: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

So, wherever possible, place multi-line text-based objects at the bottom of the section. If they require more lines to print, the section will simply expand to accommodate the growth.

Using TrueType fonts Designing your report using printer-specific fonts may lead to problems when printing to other printers. The fonts may not be supported by other printers. If they are supported, they may not be installed on other printers. If this occurs, Crystal Reports will have to make a font substitution that could create inconsistent results. It is recommended that only common TrueType fonts be used. Common True Type fonts include Arial and Times New Roman.

Using the most common video resolution If you have two identical printers, two identical printer drivers and two identical operating systems but the resolution of the video driver is different, the paging of Windows documents will be different. It is recommended that you set your video resolution to the most common video resolution. If a document is designed with the video set to a resolution of 1024 X 780 pixels and is then printed on another PC where the video resolution is coarser (such as 800 X 600 pixels), the document will encounter more formatting changes than if it was developed on 800 X 600 and moved to a finer screen resolution. Developing reports with your video resolution set at the most common and coarsest resolution will ensure that your reports will be the least sensitive to video driver settings. Unfortunately, there is no way to design Windows documents to be immune to changing video driver resolutions.

Setting specific margins Crystal Reports has the option of setting specific margins or using the printer’s default margins. If you use the default margins and then print in another environment where the printer’s default margins are greater and provide a smaller printable area, the report objects on the right size of the report will print off the page and will be truncated. It is recommended that you always set your own margins. As soon as you do so, the check box to Use Default Margins (click Page Setup from the File menu) will be cleared. If the margins you want to use are the same as your default margins, make sure that you clear this check box:

1. On the File menu, select Page Setup.

2. Clear the Use Default Margins check box. Click OK.

Changing the paper orientation To change the default printing option from portrait to landscape:

In Crystal Reports XI Release 1 and Release 2:

Select Page Setup from the File menu. From the Page Setup dialog box select Landscape.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 20

cr_printer_dependency.pdf

Page 21: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

In Crystal Reports 10 and lower:

Select Printer Setup from the File menu. From the Printer Setup dialog box select Landscape.

Note that this option will only appear if the printer is capable of printing in both portrait and landscape modes. Changing the default printing option from portrait to landscape will not change the default margins or user defined margins used by the printer. The option will change only for the particular report.

Choosing the default printer (Crystal Reports 10 and lower) In general, it is recommended that you do not choose a specific printer. While doing so will not impair Crystal Reports, it might result in complications due to the many different ways that printers are recognized on different versions of Windows.

For example, suppose an HP Laser III printer is installed on three different operating systems.

• With Windows 95, the printer name can be changed so that HP Laser III is now “Front Reception Printer”; however, the printer driver will be listed as Hppc15ms.drv.

• With Windows NT, the printer name is also referenced and can be changed by the user but the printer driver is always winspool.

• If you specify a specific printer, Crystal Reports will be looking for that printer by name. If the specific printer you specify does not exist, the default printer will be chosen. If you need to specify a specific printer, such as a label printer or a printer dedicated to printing invoices, the printer name must be the same as the machine the report was designed on. If your report is part of a distributed application, you can:

• Provide your users with a Select Printer dialog box so that they can choose the correct printer, or;

• Give the specific printer on the development machine the same name, as it would have on other computers – that is, the name of the actual printer chosen.

Continuing with the above example, you would name the printer “HP Laser III”. In this way, all clients using the same specific printer in Windows 3.X environments will be named the same (HP Laser III) and the specific printer will print the report.

For Windows clients, simply rename the printer (“Front Reception Printer”) back to “HP Laser III” or set up an identical printer with the correct default name.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 21

cr_printer_dependency.pdf

Page 22: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

If you must use a specific printer with a specific name, be aware that all your clients must have the same printer or they could encounter problems.

Maintaining default printer settings (Crystal Reports 10 and lower) If the Default Properties option is selected it allows the default printer properties to be used as it is set in the Windows Control Panel. To select the Default Properties in Crystal Reports, complete the following:

1. From the File menu, select Printer Setup.

2. Select Default Properties from the Print Setup dialog box.

Making modifications to the properties in the printer setup dialog box will cause the default properties option to become cleared.

Selecting Free Form Placement for all sections In order to create dynamic reports and reduce printer driver dependency as much as possible, it is recommended that all sections of the reports be formatted with Free Form Placement selected (in Crystal Reports XI Release 2 this isn’t an option anymore, it is always in Free Form Placement).

Report creation checklist to share reports with others • To accommodate possible growth caused by a different printer

driver measuring the fonts wider, do not place objects extremely close to each other. It is also recommended that the width of text-based objects be increased by about 5%; alternatively, the size of the fonts may be reduced.

• Consider where, and how, you place multi-line text-based objects. If you have objects placed directly below multi-line text-based objects and in the same section, a different printer driver could cause the multi-line text-based object to require an additional line causing the object below to be over-printed. Keep in mind that the number of lines necessary to print the text-based object could differ from that required on the development PC.

• Use Windows TrueType fonts where possible. These are the most common fonts; they are readily available on all versions of Microsoft Windows and can be realized on all printers.

• Use the most common video driver settings.

• Set specific page margins.

• After the report is completed and you are happy with the results, format every section to have Free Form Placement selected.

• Remove all guidelines from the reports.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 22

cr_printer_dependency.pdf

Page 23: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

The report should now be in a state where it is the least sensitive to changing printer drivers and ready for distribution.

As you design your report, you are free to use whatever methods you choose to create the look and feel that you want in your report. Bear in mind, however, that the more of the above suggestions that are incorporated into your design, the less sensitive your report will be to different printing environments

Tips and tricks Duplex printing in Crystal Reports Duplex printing is dependent on the type of printer you have. You must verify that your printer supports duplex printing. Crystal Reports does not control a printer's duplex printing ability. The printer driver for the printer handles the duplex print control. In order to print in duplex mode you must verify the following:

• The duplex printer must be set as the default printer in Windows.

• The report must have the default printer selected in the Printer Setup dialog in Crystal Reports.

For more information on duplex printing see knowledgebase article C2000600 - Printing a certain group field only at the top of every odd page.

Printing subreports in different formats In Crystal Reports, you can format the main report and subreport to print in either Portrait or Landscape orientation. This is because the subreports are considered part of the main report and maintain formatting of the main report. Therefore, individual landscape or portrait page formatting cannot be set and only portrait or landscape formatting can be set for the entire report.

Printing is slow when using a dot matrix printer When printing in Crystal Reports a virtual page (virtual picture) is generated. Therefore, when printing to a dot matrix printer the printing speed is very slow. A dot matrix printer will take longer to print a picture type file. Therefore, the suggested workaround is to export the report to text format and print the exported file.

It is also possible to apply Text Mode settings to a dot matrix printer to improve printing speed. Printing in Graphics Mode can result in a better quality print out, however the printing speed is slower. For more performance related tips on printing speed see the Technical Paper scr_printspeed.pdf.

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 23

cr_printer_dependency.pdf

Page 24: Crystal Reports - Archive · Crystal Reports Printer Driver Dependency Crystal Reports architecture The Crystal Reports architecture offers the ability to print consistent-looking

Crystal Reports Printer Driver Dependency

Finding more information For more information and resources, refer to the product documentation and visit the support area of the web site at: http://www.businessobjects.com/

6/13/2007 12:07 PM Copyright © 2007 Business Objects. All rights reserved. Page 24

cr_printer_dependency.pdf