Mihail Radu Solcan

  Insert annotations behind the djvu image of handwritten text

2008-12-23; corrected on 2008-12-28

The problem is similar to the one that I have discussed in the note on the insertion of text behind the image of a handwritten text. Again, we have the image of a manuscript, but this time we want to see tips when we move the cursor on the areas of the image. 

For the problem and its solution see DjVu.org. Here we use GPL compatible tools. The aim is also a bit different. I have in mind “small tasks” that might arise on a personal page. For example, I do have some old papers and books that I would like to present on the page with annotations. 

The most important tool will be again the Box Editor. I will also use the gridMaker from the text-into-djvu package. All the new files discussed bellow are in the ant-in-djv archive. 

The grid and the adjusted boxes

I start with the gridMaker and the image of the quotation from Shakespeare. 

./gridMaker.py wsh.tif

I will use the adjusted boxes. Remember to Save Box Info in the Box Editor before closing the editor! You close without saving, then you lose all the changes. No attentioning! 

The script for djvused

In the next step you write the commands for djvused. In my case, I extend the vim menu. Without it it is rather difficult to edit the djvused script. 

I will name the script wsh.atxt; this is the script for the text of the annotations (so it's “atxt”). 

The script for the insertion of annotations

The syntax of the annotations script used here is the basic one. The core of the script is formed by lines of (maparea…) sequences. It is easy however to see where are the words. The “rect” keyword tells djvu that the coordinates are for a rectangualar area. You have to insert them with Ctrl+A in the Box Editor. The third number indicates the width of the area. The fourth number is the height of the area. 

Insert the annotations

Now, I take the wsh.djvu and I insert the annotations with the command:

djvused wsh.djvu -f wsh.atxt -s

View the djvu with annotations

The last step is to view the djvu in the DjVu viewer

Tip on the image

Now I have the tips when I move the cursor on the djvu (try this with the wsh.djvu in the archive). 

I have not removed the text, so I have it. It is possible to find words in the text too. 

Text and tips on djvu

The Syntax of DjVu annotations

The syntax of the annotations is described in the djvused documentation

It is possible to change the shape of the area. The coordinates for the rectangular are can be used for the oval area. For example:

(maparea "" "players" (oval 36 42 179 76) (none))

The option “(none)” means that no border is drawn around the area. If you want to draw a border, you may write:

(maparea "" "players" (oval 36 42 179 76) (border #00ffff))

The sequence “00ffff” indicates the color of the border. The border is visible only when the cursor is in the area. If you want to make it always visible, add “(border_avis)”. 

(maparea "" "stage" (oval 148 307 152 52) (border #00ffff) (border_avis))

If you want to color the area, you use this kind of syntax:

(maparea "" "stage" (rect 148 307 152 52) (hilite #cccf00))

The “(hilite …)” option may be used only for a rectangular area. 

In djvu e-books, you might find use for this kind of expressions:

(maparea "#15" "see Contents" (rect 940 1925 105 25) (none) (hilite #0000ff))

This will highlight in blue a rectangular area and show the tip “see Contents”. When the arrow appears and you click on the blue area, the DjVu viewer goes to page number 15 (this works in DjView4). 

The novelty in the script was the indication of the URL (in this case, a location in the same document). See the documentation for further details.