Wednesday, September 24, 2008

Step 3 - SVG template fitting with data.

Current status. Now I have a SVG viewer and SVG printer. Both of them are working, one issue  what I left with is a precise size of the printed out SVG document, but almost sure I will be able to fix it.

Now I have to merge product's data from database with SVG template and get an output SVG file suitable for printing. All SVG template files are produced by professional graphic designers, they are designed on Corel Draw and then exported to SVG file format. These template files have to be updated with data what are retrieved from database. To do that job I see two general options, to use any templating language or XSLT. Independently on any chosen option it's preferable to have a clean easy readable and ordered SVG file.

Few days ago, I took a first look at source of exported SVG file. I wasn't been impressed by it's quality. I did expect to have to do some manual editing of produced file, but never thought about so horrible result. Actually I found a few major issues, what I had to solve. The first issue was , text was distributed over separate small text nodes. Some sentences was chunked to separate words, even some words had separate text node for every single letter. Other issue, oder of text information in template file was randomly distributed over all the file. 

As I said in my previous posts I have quite a few options to use: FreeMarker, XSLT, Velocity. After some tests I bet on Velocity. Some samples will follow in following posts. 

The hardest part is how to get exact visual result of the label. In order to achieve that I was forced to start using some SVG tags from SVG version 1.2. Result I got back is good enough, still have to do some little tweaking.


No comments: