Converting DigiMemo files to Jarnal format

Update (Sept. 29, 2009): I got in touch with Kevin Lindsey, the author of the script discussed below for converting DigiMemo DHW files to SVG format. He’s put his code on github, and written a new blog post about it.


For taking notes physically on paper, I use an ACECAD DigiMemo L2 digital notepad (whom I have named Little Wooden Boy).

Because I use Linux primarily, I don’t use the Windows-based software provided by ACECAD. Instead, I use Jarnal, an open source note-taking application written in Java.

This poses a minor problem, as the DigiMemo products store their output in a proprietary ACECAD format called DHW. Fortunately, Kevin Lindsey had already gone to the trouble of asking ACECAD for the specification of the DHW format, and better yet, he has even whipped up a Perl script to convert DHW files to the SVG open standard.

Jarnal’s file format is in fact just a standard ZIP file containing a plain text configuration file and a number of SVG files, one for each page in the document. So far, so good. Unfortunately, Jarnal’s ability to read SVG files produced by other programs is not very robust. In order to convert DHW files to SVG files which are readable by Jarnal, a number of changes have to be made to Kevin Lindsey’s original Perl script.

Note that the changes which I’ve made are specifically for the DigiMemo L2. If you have a device with different dimensions, for example, you will have to tweak some of the parameters that I’ve used (such as the values of 924 and 714 that I’ve assigned to the virtual height and width of the drawing surface).

First, download the script from Kevin Lindsey’s blog entry here. The file to download is named “DigiMemo.zip”. Extract the file named “DigiMemo_SVG.pl”, and make the changes described in the following paragraphs.

In the “emit_header” subroutine, locate the following lines:

133
134
135
136
137
138
139
140
141
    print STDOUT <<EOF;
<svg viewBox="0 0 $width $height" fill="none" stroke="black" stroke-width="10" stroke-linecap="round" stroke-linejoin="round">
    <rect width="$width" height="$height" fill="aliceblue"/>
EOF
    emit_comment("id = $id");
    emit_comment("version = $version");
    emit_comment("width = $width");
    emit_comment("height = $height");
    emit_comment("page type = $page_type");

And replace them with these ones:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
	print STDOUT <<EOF;
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width="714px" height="924px" xmlns="http://www.w3.org/2000/svg">
<title>Jarnal document - see http://www.dklevine/general/software/tc1000/jarnal.htm for details</title>
<desc>
[Jarnal Page Parameters]
paper=Lined
lines=35
height=924
width=714
bg=1
transparency=255
bcolor=-1
bgtext=false
bgfade=0
bgrotate=0
bgscale=1.0
bgid=none
bgindex=0
</desc>
EOF

The Perl script will now generate SVG files with a header that Jarnal can read. But we’re not done yet. In the “emit_comment” subroutine, delete the following line:

154
    print STDOUT "    <!-- $message -->\n";

Finally, in the “emit_polyline” subroutine, locate the following lines:

164
165
166
167
168
169
170
171
    my @points = map {
        $_->[0] . "," . $_->[1];
    } @$coords;
    my $data = join(" ", @points);
 
    print STDOUT <<EOF;
    <polyline points="$data"/>
EOF

And replace them with these ones:

1
2
3
4
5
6
7
8
    my @points = map {
        int($_->[0]*71400/8500)/100 . " " . int($_->[1]*92400/11000)/100;
    } @$coords;
    my $data = "M" . join(" L", @points);
 
    print STDOUT <<EOF;
    <path d="$data" stroke="black" stroke-width="0.6" fill="none"/>
EOF

Now the script will produce SVG files which are fully readable by Jarnal. However, it still only converts one file (i.e., one page) at a time. To produce a Jarnal document containing multiple pages, we’ll need to create some additional scripts.

Create a bash file named “digimemo-template” with the following content in “/usr/local/bin”, and give it execute permission:

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
if [ "$1" = "" ]; then
	echo "Usage: digimemo-template [filename]"
else
	if [ -f "$1.jaj" ]; then
    	echo "ERROR: file \"$1.jaj\" exists."
        exit 1
    else
		cp "/path/to/jarnal/templates/digimemo.jaj" "$1.jaj"
		echo "File \"$1.jaj\" created."
        exit 0
    fi
fi

The above assumes that you have a Jarnal template file named “digimemo.jaj” located in the “/path/to/jarnal/templates” subdirectory. Change it as appropriate. Now, running “digimemo-template filename” will create a Jarnal file named “filename.jaj” in the current directory.

Next, create a Perl script named “digimemo.pl” with the following content in “/usr/local/bin” and give it execute permission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w
use File::Temp qw/ tempdir /;
 
if ( @ARGV > 0 ) {
    system("digimemo-template $ARGV[0]\n");
    if ($? == 0) {
        $tempdir = tempdir ( "digimemo-XXXXXXXX", TMPDIR => 1 );
        print "Creating temporary directory: " . $tempdir . "\n";
        $count = 0;
        foreach $file (<*.DHW>) {
            print "Converting " . $file . " > $tempdir/p$count.svg\n";
            system("DigiMemo_SVG.pl " . $file . " > $tempdir/p$count.svg");
            $count++;
        }
        print("zip -j $ARGV[0].jaj $tempdir/p*.svg\n");
        system("zip -j $ARGV[0].jaj $tempdir/p*.svg");
        print "Created new digimemo Jarnal file: $ARGV[0].jaj\n";
    } else {
        print "Failed to create new digimemo Jarnal file.\n";        
    }
} else {
    print "digimemo.pl [filename]\n";
}

Running the command “digimemo.pl filename” will convert all of the DHW files in the current directory to SVG format, and then bundle them up in a ZIP file named “filename.jaj”, which can now be opened using Jarnal.

Since Jarnal can output PDF files, this serves as a way of converting DHW files to that format as well.

– davinci 11778

If you like this post, you might also like:

  1. Annotate With Jarnal Plug-In Module for Wikindx

5 Responses to “Converting DigiMemo files to Jarnal format”


  • Thank you for this post. I’ve just received an AceCad Digimemo 692 that I’m going to run on an Apple Mac Aluminum PPC PowerBook G4, running OSX (10.4.11 Tiger). I think I can figure it out with the help of this link. I found this posted at the AceCad website.

  • Hello,

    I am currently running Ubuntu Karmic Koala and I installed Jarnal via the .deb package that was in the official website and then I proceeded to do everything you outlined in your instructions and it doesnt run, I then tried downloading the zip file and running it with the jarnal.sh and it doesnt work.

    when I type jarnal in the terminal I get the following message:

    [code]chacmool@link:~$ jarnal
    /usr/bin/jarnal: line 17: 6639 Aborted java -Xmx192m -jar ${JARNALDIR}/jarnal.jar -g -t ${TEMPLATESDIR}/templates/default.jaj "$1" "$2" "$3" "$4" "$5"
    chacmool@link:~$[code]

    What did I do wrong?

    • I’m not sure which instructions you’re referring to as I’m not the author of Jarnal. Which java are you running? For example, what happens when you type “java -version” into a terminal?

      – davinci

  • Helló, most fedezem fel a blog a Yahoo, és megállapította, hogy ez tényleg félelmetes. Meg fogom nézni ki Brüsszelben. Én értékelem, ha folyamatosan írt ebben a témában a jövőben. Sokan részesül az írás. Egészségére!

Leave a Reply