• No results found

Crystal Reports 5, 6, 7 & 8

N/A
N/A
Protected

Academic year: 2021

Share "Crystal Reports 5, 6, 7 & 8"

Copied!
23
0
0

Loading.... (view fulltext now)

Full text

(1)

Crystal Reports 5, 6, 7 & 8

Printer Driver Dependency: How to design reports that print

consistently in different PC environments

Overview

This document addresses the problem of Crystal Reports (CR) printing inconsistently on different machines and explains why Microsoft Windows programs are dependent upon printer drivers when printing documents. Discussion focuses on exactly how CR handles the formatting, placement and printing of the many objects that exist in reports. With this knowledge, developers and other CR 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 & tricks, and design criteria are provided to help you make use of the increased functionality of Crystal Reports versions 5.x, 6.x, 7.x and 8.x.

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

(2)

Contents

HOW MS WINDOWS PROGRAMS USE THE PRINTER DRIVER TO PAGINATE A

DOCUMENT... 2

AN EXERCISE IN PRINTER DRIVER DEPENDENCY... 4

HOW PRINTER DRIVER DEPENDENCY AFFECTS DISTRIBUTED REPORTS... 5

Text-based objects ... 5

OLE objects ... 6

Combining text-based and OLE objects... 6

CRYSTAL REPORTS ARCHITECTURE... 6

CHARACTERISTICS OF OBJECTS IN CRYSTAL REPORTS... 6

Individual text-based objects and truncated text...6

Suggested workarounds ...8

Memo fields and multi-line text objects ...10

CHARACTERISTICS OF REPORT SECTIONS IN CRYSTAL REPORTS... 10

How Crystal Reports controls the placement of objects ...12

Introduction of Free Form Placement ... 12

Free Form Placement of objects selected... 13

Using grids and guidelines... 15

DESIGN CONSIDERATIONS: DISTRIBUTING REPORTS IN DIFFERENT PC ENVIRONMENTS... 17

Correctly spacing text objects ... 17

Placing text objects close to other objects... 17

Placement of multi-line text objects... 18

Using TrueType fonts ... 18

Use the most common video resolution ... 18

Setting specific margins... 18

Changing The Paper Orientation... 19

Choose the default printer... 19

Maintaining Default Printer Settings ... 19

All sections to have Free Form Placement selected ... 20

Remove all guidelines... 20

REPORT CREATION CHECKLIST FOR DISTRIBUTED REPORTS... 20

TIPS & TRICKS... 21

Duplex printing in Crystal Reports ... 21

Printing subreports in different formats ... 21

Printing is slow when using a Dot Matrix printer ... 21

Showing all header information in drilldown... 22

CONTACTING CRYSTAL DECISIONS FOR TECHNICAL SUPPORT... 22

How MS Windows programs use the printer driver to paginate

a document

All Microsoft Windows programs require the printer driver to paginate a document. Printer drivers measure font information, based on the particular font selected (Courier, Courier New True Type Font (TTF), Arial TTF, etc), 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

(3)

accepted by the printer driver. True type fonts are WYSIWYG 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 MS 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 MS 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 MS 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.

• 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 MS 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.

(4)

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.

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 MS Windows. Different programs and different drivers will illustrate varying degrees of difference. Also, the same printer driver used in a different version of MS Windows will yield different results.

At Crystal Decisions, the first line of this 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)”, while “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.

(5)

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 CR 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 required to own Crystal Reports in order to view their reports. While this functionality allows developers to distribute a great report writer ‘royalty free’, it also means that their customers do 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 issues that developers and distributors could encounter and must consider when designing reports.

Text-based objects

The first issue 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 CR 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.

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

(6)

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. Secondly, 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 issue 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.

Crystal Reports architecture

The Crystal Reports version 5, 6, 7,and 8 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 entitled ‘Design considerations when distributing reports in different PC environments’ presents a methodology to designing sophisticated and consistent looking reports.

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.

(7)

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 e’s (which are slightly 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 7 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

(8)

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 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?

Obviously, 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:

1. If you format the text-based object to print on multiple lines (on the Format menu, click Format Field…select the 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 dependency P r i n t e r d r i v e r D e p e n d e n c y

Dependency D e p e n d e n c y

Printer driver on development PC

Printer driver on client’s PC that measures fonts wider

(9)

2. 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 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 obviously 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 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 that 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.

(10)

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 (on the Format menu, click Format Field…select the 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.

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.

Notice here that 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.

How to manage 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

(11)

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, choose 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-text-based object determines a line’s height with largest font on the line. All text-based 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 figure 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 figure), 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. That is displayed in the figure 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 2 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 determines 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.

(12)

How Crystal Reports controls the placement of

objects

In Crystal Reports version 5, 6 and 7 each section’s upper left corner is given the X and Y coordinates of (0,0). CR 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 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 is (720,432). When it is time to evaluate and print the Details section, CR will know where to start printing the object by referencing these X and Y coordinates.

Introduction of Free Form Placement

Crystal Reports version 5, 6,7, 8 and 8.5 offer a choice of how vertical placement of objects is to be determined:

1. On the Format menu, choose Section.

2. The Free Form Placement check box (upper right) can be selected or cleared.

This setting will determine how CR 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 is 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 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

(13)

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 CR 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 CR (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, CR 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.

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 objects 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.

(14)

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 based objects placed beside one larger text-based object.

Notice 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 CR where to place and print the objects have been 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 CR but the interline and character spacing of these five lines will be determined by the printer driver.

(15)

Using grids and guidelines

Each section of a report contains a design grid. The grid always exists;

however, CR 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 are displayed in the lower left section of the Options dialog box.

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.

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

CUSTNUM

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

CONAME

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

(16)

STATE

This field was inserted and then the bottom boundary was dragged down. Notice that the bottom boundary also snapped to the grid line but the font size did not change.

CITY

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

COUNTRY

This field was placed on the report when Snap to Grid was not selected. Notice that the object did not move and its boundaries did 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).

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 was first inserted, its baseline snapped to the guideline. When the upper border was then resized by dragging the object’s upper border upwards, the object assumes the characteristics of Snap to Grid. When PHONE was first inserted, its baseline also snapped to the guideline. However, when it was resized by dragging the bottom boundary

(17)

downward, the object expanded but the precedence of the text snapping to the guideline, instead of the grid line, was 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.

Design considerations: distributing reports in different PC

environments

Listed below are several design hints for creating reports for distribution.

Correctly spacing text objects

While it is best to have Free Form Placement selected (more about this decision later), spacing text objects evenly in such an environment is difficult. An alternative is to initially clear Free Form Placement. Then, when you expand the section, a guideline will be added for each line and the spacing will be

consistent. When all objects have been placed in the section, select Free Form Placement and remove the guidelines.

An alternative is to use Snap to Grid in conjunction with guidelines as described in the section above, “Using grids and guidelines.”

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 perfect. 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.

(18)

Placement of 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. Previous versions of Crystal Reports would have pushed down the object positioned below the multi-line text object if additional lines were required, and would not have allowed the object above to over-print it. However, version 5.0 does not push objects down, it only pushes sections down.

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 or, while they may be 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.

Use 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 MS Windows documents will be different. It is recommended that you set your video resolution to 640 X 480 pixels. If a document is designed with the video set to a resolution of 800 X 600 pixels and is then printed on another PC where the video resolution is coarser (such as 640 X 480 pixels), the document will encounter more formatting changes than if it was developed on 640 X 480 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

CR 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 (File | Page Setup) 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.

(19)

Changing The Paper Orientation

To change the default printing option from portrait to landscape, select ‘Printer Setup’ from the ‘File’ menu. From the ‘Printer Setup’ dialog box select ‘Landscape’. 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.

Choose the default printer

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 Microsoft 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.

• In Windows versions 3.X, the printer is recognized by the name of the printer, in this case HP Laser III and the printer driver is Hppc15ms.drv. If you specify a specific printer, CR 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 in a Windows 3.X environment – 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 95 and Windows NT clients, simply rename the printer (Front Reception Printer) back to HP Laser III or set up an identical printer with the correct default name.

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

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:

(20)

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.

If you do not select a default printer, Crystal Reports 8.x will prompt you with the following warning message:

“Before you can print, you need to install a printer”.

And, in Crystal Reports 7.x and lower, the following warning message appears: “There is no default printer”.

You must install a printer through the Windows Control Panel if you want to change the paper orientation in Crystal Reports.

All sections to have Free Form Placement selected

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.

Remove all guidelines

If objects are snapped to guidelines, they are, in essence, still bound to lines even though Free Form Placement is selected. Thus, to obtain true Free Form Placement, all guidelines must be removed once the design of the report is complete.

Report creation checklist for distributed reports

• 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 and coarsest video driver settings. It is recommended that you set your video driver resolution to 640 X 480. • Set specific page margins.

• Do not choose a specific printer. Choose the default printer unless your application or compiled report needs a specific printer that your client will have and the printer name is the same on both the development machine and your customers’ machines. Specific printers are usually for point of

(21)

purchase forms, invoices and specific label printers. If you must choose a specific printer, make sure it is named the same name as it would be named in a Windows 3.X environment.

• 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.

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 & 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’ 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. 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 check out the white paper “scr_printspeed.pdf”.

(22)

Showing all header information in drilldown

In Crystal Reports version 8.x, it is possible to print all header information. To do so, complete the following:

1. From the ‘File’ menu, select ‘Report Options’. 2. Select ‘Show all Headers on drilldown’.

Prior to Crystal Reports version 8.x it was not possible to select this option.

Contacting Crystal Decisions for Technical Support

We recommend that you refer to the product documentation and that you visit our Technical Support web site for more resources.

Self-serve Support: http://support.crystaldecisions.com/ Email Support: http://support.crystaldecisions.com/support/answers.asp Telephone Support: http://www.crystaldecisions.com/contact/support.asp

(23)

References

Related documents

The lift to drag ratio increases as the angle of attack increased on both wings, for rear wing the lift to drag ratio is reduced when compared to that of front wing due to

In this paper we develop a dynamic data-consistent way for estimating agricultural land use choices at a disaggregate level (district-level), using more aggregate data

Mackey brings the center a laparoscopic approach to liver and pancreas surgery not available at most area hospitals.. JOSHUA FORMAN, MD

The Modified Principal Component Analysis technique shall take care of issues such as problem arising from the reconstruction of the face images using their corresponding

For example: On the 6” to 8” template, the Solid red index mark represents a spacing of 6 inches, the dotted blue index mark represents a spacing of 7 5/8 inches.. What this means

Shelley said, "The imagination is the great instrument of moral good, and poetry administers to the effect by acting upon the causes." Through great literature we are

This study more deeply examines the effect of fast paced music on reducing aggressive behaviors when transitioning children with autism.. This study will specifically look

Medical / Dental / Vision Parenting Classes Senior Services Transportation Utility Assistance Veterans Services.. NOTE: Information in this directory is continuously