Configuring Report Page and Margin Properties

With Crystal Reports, margins can either be set to use specific manually set margin definitions or can be selected to automatically adjust to the report margins. To set your report margins to meet exact specifications, follow these steps:

  1. From the File menu, click Page Setup, and the Page Setup dialog appears as shown in Figure 6.17.

     

    Figure 6.17. The Page Setup dialog is used to specify report margin settings.

     
  2. Modify the default page margins for your exact requirements.

     

  3. Click OK to save your changes.

     

NOTE

Each of the margin settings is calculated from the paper edge. Consequently, a left margin of .25 inches causes the printing of the report page to start exactly one quarter of an inch in from the left edge of the paper.

As an alternative to specifying exact report margins, you can select the Adjust Automatically check box if you want Crystal Reports to adjust the report's margins automatically when the paper size changes. This option maintains the ratio of the margins to the printable area of the report by enlarging or reducing the left/right and top/bottom margins by the same factor. For example, this setting could ensure that a report designed for a printer that can only print within .5 inches of the paper's edge would maintain the same overall margin ratio when printed on a printer that could print to within .25 inches of the paper's edge.

TIP

If you decide to select the Use Default Margins options for your reports, there are two common issues to be aware of when printing reports (also described in the Crystal Reports Help files):

As a result, it is recommended that you specify your own report margins. It is encouraged that you do not select the Use Default Margins option in the Page Setup dialog to avoid these common problems. It is advisable to set your report margins manually using the Page Setup dialog, even if the margins you want to specify are the same as the default margin settings. This issue becomes especially important when you distribute your reports over the Web and have no idea what type of printer the business user will be using.

Crystal Reports in the Real WorldReferencing External Resources

A very powerful use of hyperlinks is to be able to take advantage of the many resources on the Internet. Many Internet sites make use of what is called a QueryString. By knowing the URL and QueryString that drive a particular site, a report hyperlink can be customized to open a Web site and perform some functionality. In the next example, the address of the sample customers can be opened in MapQuest.com by using a hyperlink:

  1. Start with opening the report Chap6PostFormat.rpt. From the Insert menu, choose Text Object. Add the text MapQuest to the report.

     

  2. Right-click the newly added text object and choose Format Tex. Then click the Hyperlink tab and click the x+2 button. See Figure 6.18 for an example of what the formula should look like. Enter the following code into the text:

     

       

    StringVar URL; // The prefix of the URL that will not change; it is hard-coded to the USA URL := "http://www.mapquest.com/maps/map.adp?"; URL := URL & "country=US&countryid=250&adtohistory="; // Add the street address URL := URL & "&address=" & {Customer.Address1}; // Add the city URL := URL & "&city=" & {Customer.City}; // Add the state URL := URL & "&state=" & {Customer.Region}; // Add the ZIP code URL := URL & "&zipcode=" & {Customer.Postal Code}; // Add the suffix of the URL URL := URL & "&submit=Get Map"; URL  

    Figure 6.18. Code that builds a dynamic data driven URL that will enable hyperlinks to the Mapquest Web site from a Crystal Report

     
  3. Click Save and Close to close the code window. Click OK to close the Format Editor window. Format the hyperlink using the same method used to format the e-mail address to show the user it is an actionable item.

     

NOTE

The sample data does not necessarily use valid addresses. MapQuest.com might open with only partial information, but the concept remains valid.

Категории