Category Archives: Crystal Report Tips and Tricks

Enable/Disable Snap to Grid feature on Crystal Report XI

I need to update/Re-Create some Crystal Reports from Crystal Report 8.5 to Crystal report XI [Kind of redo the Report into New version].The most annoying thing is to layout the fields/items properly into the report.
Sometime you may want to drag the field into a specific position or want to make the Textbox, Box/Line slightly bigger or smaller. Even move it little bit upward…etc.
You will find that the Textbox/Box/Line always snapped into the grid.
What you can do is to disable that feature. Then you can drag the fields/controls to wherever you want. = ).
Unfortunately the “Snap To Grid” feature is not placed on the normal place. E.g. “Edit/View” menu… After spending sometime on it, I worked out how to do it.
Solution:
1) Open up the design screen
2) Right click on the “ruler“.
3) Then you will see a menu appear
Snap To Grid feature Crystal Report
4) You just need to click on the “Snap to Grid” option to make sure it does not have the tick next to it.
5) if you want to enable it again, you can do the process above to enable “Snap to Grid” feature.
Hope you find this useful

Crystal Report Convert Time Format From Seconds to HH:MM:SS

Some of the Crystal report that I need to generate involve conversion between Seconds to Hours:minutes:seconds.
I spend quite a long time to search on internet and work out how to do it and experienced some bugs on one of the Crystal Report formula that I build before had a bug.
I am not sure why it only works on some computer, but not the other.
E.g. it always display 2 decimal places at the end i.e. 1.00. (Although I use Mod to retrieve the reminder of the number, which mean it should not have any decimal place at all)
Anyway, here it is the formula/code that I use to convert Seconds to HH:MM:SS
Hope you find it useful:

numberVar dur;
dur := {Field/Value/Seconds you want to convert};
numberVar hrs;
numberVar min;
numberVar sec;
stringVar hhmmss;

hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
sec := Remainder(dur,60);

hhmmss := totext(hrs,”00″) + “:” + totext(min,”00″) + “:” + totext(sec,”00″);

hhmmss

Crystal report XI Service Packs 5 solve the PDF font size get reduced/smaller issue

Today I just have a look at the documentation about Crystal report XI Service Packs 5, which has released at the end of Nov 2008.
They have mention the PDF generation issue which I posted few days ago about PDF font size get reduced after you export it from crystal report.

If you have similar issue, the following description may be able to help you get around it.

Hope you find it useful.

ADAPT00940675
Description:
The registry key option ForceLargerFonts maintains the correct font size of reports that are exported to PDF format; however,
this option may cause data to be truncated along the right-side margin.
The problem is caused by a mismatch in the way that character widths are calculated between PDF and Microsoft Windows.
New Behavior:
This problem is resolved.
To solve the problem, the PDF export engine has been modified to use an algorithm that positions characters precisely to
prevent truncation, while still maintaining the correct font size. This algorithm is activated and controlled by two new registry
keys:
[HKEY_LOCAL_MACHINESOFTWAREBusiness Objects\Crystal ReportsExportPdf]
“UsePrecisePositioningForText”=dword:00000001
[HKEY_LOCAL_MACHINESOFTWAREBusiness Objects\Crystal ReportsExportPdf]
“TruncationAdjustment”=dword:00000002
The UsePrecisePositioningForText key enables the new functionality when it is set to 1. When this option is enabled, the
ForceLargerFonts option is automatically enabled (to maintain correct font sizes in PDF exports), and any manual settings
made to it are ignored. The TruncationAdjustment key controls a width calculation rounding function in the new algorithm and
accepts values between 0 and 10 inclusively. The default value of 2 has been tested to sufficiently eliminate most truncation
issues. If truncation still happens, users can increase the value.
Known Limitations:
When the UsePrecisePositioningForText key is enabled, exports to PDF format may take slightly longer, but by no more than
10%. Also, the exported PDF document will increase in file size over the standard output, and Crystal reports will consume
more GDI resources during the export.

WordWrap on Crystal Report?

I have received a task to convert the project handbook from Word Document into Crystal report. It does not sound difficult until I need to do some formatting and Layout.

I had a problem on trying to make a field to display in Multi-line, instead of one line. And I am not able to file a word wrap function on Crystal Report. After spending some time on the web. Finally I find out how to do it.

Solution:

1) Select the field(s) that you want to enable WordWrap.

2) Right click and select “Format Field” OR “Format Objects” (if you select more than 1 fields)

3) Then in the “Format Editor” Click on the “Common” tab.

4) You will see the screen shot similar as below.

Crystal Reports fields Format Editor

5) Then “Tick” the “Can Grow” check box and click “OK”

6)After you done that you can save the Report and press “F5” to preview the report.

Hopefully you the field will be wrapped into next line.

Good luck