Mono, Gnome.Print and Pango

When we submitted the design practical assignment, Catedrax used NeoDataType as its report generator. This is a free generator, but not libre, so we decided to stop using it.

I started looking on SourceForge for some replacement, but I couldn’t find anything convincing. Now an additional requirement is that it works with Mono, since we switched to this free implementation of .NET.

So I started looking at the Gnome.Print documentation (printing API for Gnome), and tried some examples. Now I have put together a project, MonoReporter, a report generator for Mono. Soon, when I have something more polished, I’m going to publish it.

Pango is an API for advanced font handling. I started using it when I saw the need to center text in a cell, for example. That is, to center it I need the text measurements, and this can’t be done with Gnome.Print. Something more advanced is needed.

For now, this is the code needed to create a report:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
report = new Report ("Test report", 75, 50, 75, 50);
Pagina page = report.AddPage();

string[][] data = new string[10][];
for (int i=0; i<data.Length; i++)
        data[i] = new string[3];

data[0][0] = "Name";
data[0][1] = "Last name";
data[0][2] = "City";

data[1][0] = "Milton";
data[1][1] = "Pividori";
data[1][2] = "Avellaneda";

data[2][0] = "Name1";
data[2][1] = "Last name1";
data[2][2] = "City1";

double[] width = {125, 125, 200};
Table table = new Table (page, 55, 800, "Students list", data, width);
page.AddObject(table);
report.Print();

That code generates this:

Reporte

Yes, it’s a VERY humble report. But the important thing is that the basic steps are already done.

There are things that are excessive in the previous code: The user shouldn’t add the pages, MonoReporter would take care of this. That’s true, but for testing purposes, it will stay like this until I release a functional version. Another issue is the array of string arrays: that shouldn’t go there, but a DataTable instead.

It would be good to be able to use something that already exists, like JasperReports, but this is only available for Java. Here we can talk about one of the advantages of the .NET framework: language independence. There is a project, IKVM.NET, that tries to be a Java implementation for .NET and Mono. Unfortunately, although it enjoys active development, it lacks a good AWT implementation (used by JasperReports), and from the project page we read:

IKVM.AWT.WinForms.dll: Very limited and broken implementation of a few AWT peers. This is a low priority issue for me.

So let’s not expect to use, at least in the short term, that report generator. I will continue with MonoReporter…

Licensed under CC BY-NC-SA 4.0
Last updated on Jun 03, 2006 00:55 UTC
comments powered by Disqus