Adding watermarks to Crystal Reports

Here is the latest tip from the Flexible Solutions GP Reports Newsletter: how to add a watermark to your Crystal Reports.  I am going to demonstrate with an example.

I have created a statement report, but it’s a little bland, especially when there are only a few lines of data to show:

First step is to copy the watermark image to the Page Header section. On my report I was not using the page header, so I could put the watermark there. If your report is already using the page header, you can add an additional page header by right clicking on the Page Header section and choosing Insert Section Below:

Once you insert the watermark image you may need to re-size it or reposition it lower so that it is does not show up at the top (unless that is what you want).

Now go to Report > Section Expert, click on the Page Header (if you created a new section, it will be Page Header b) under Sections and check Underlay Following Sections on the Common tab:

Click OK and go to your report Preview. I had to go back and move my watermark down some more, but here is the end result:

You can sign up for the GP Reports newsletter to get these tips monthly or you can see the archived newsletters on the Flexible Solutions News & Events page. You can also see a list of all the Crystal Reports tips published so far on my GP Reports page under Working with Crystal Reports.


Download File using PHP Code

This is my favorite download-script, it works with files bigger than 10 MB on Apache 1.3 (or higher). I added the cache control to open also text files and others (without saving). Use this example code to download files from a protected directory for example.


// place this code inside a php file and call it f.e. "download.php"
$path = $_SERVER['DOCUMENT_ROOT']."/path2file/"; // change the path to fit your websites document structure
$fullPath = $path.$_GET['download_file'];

if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
fclose ($fd);
// example: place this kind of link into the document where the file download is offered:
// <a href="download.php?download_file=some_file.pdf">Download here</a>

Added an example how to use this script with the filename from a query string
Mved the disposition header into the switch because the attachment attribute is sometimes needed
Using the function pathinfo() to get the file information (extension) now
Added the function stringconv() to handle also extensions with caps.

The demo page demonstrate the functions file upload / download and handle directories

DLL registration

Ever been stuck or advised to manually register a DLL on your or a client machine and been left scratching your head?

Here is what I do to save some time or test a file.

1. Open Explorer and locate the dll/ocx you are wanting to register.  You could also use the Search for files function.
2. Click Start >> Run
3. Type Regsvr32 in the Open Box
4. Drag and drop the DLL from the Explorer window into the Open box right after Regsvr32
5. Click OK

You should now be presented with a dialog informing of the status of that action.

1. If in the resulting dialog you see the message
“Entry point not found”

This would be an indication that the DLL does not need to be registered.  Hence the ‘No entry point’

CRYSTAL NOTE: –> The export format and destination and data access drivers do not need to be registered.

2. If the DLL is registerable (and all dependencies are present**, you should see a “…registered successfully..” message.

**If you have a DLL that you know needs to be registered, but fails, you can use a tool like Dependency Walker ( to open the dll (.exe or .ocx) and it will alert you to the problem component(s).

Of course this is not an all encompassing FAQ, but meant to provide a quick and painless way to try registering a DLL if it is a part of your troubleshooting.  If you are not sure the file needs regsitering, try it.