Jump to content

BIRT Developer Center

DevShare Source for user-contributed BIRT articles, tips and code

Devshare Home >> Creating a ReportDocument without file access
- - - - -

Creating a ReportDocument without file access

Download Resource


Using a MemoryArchive to create a ReportDocument without file access.

Full Description:

When creating a ReportDocument for example to extract data from a report or to store the documents bytes somewhere, BIRT API provides two ways. First is running 'ReportEngine.openReportDocument(String string)' with a string containing a file path. Second is running the method with A IDocArchiveReader object. Both ways are using files in the background. If however any file access is unwanted there is currently no simple way provided by API to do so.
I've written a MemoryArchive Class (implements IDocArchiveWriter and IDocArchiveReader) that may be used for this purpose.

I wrote an IDocArchiveReader and IDocArchiveWriter implementation that uses memory byte fields only to create a document. It passed all my tests. However, I cannot assure that everything works with it! Especially the listStreams:relativePath. String method remains untested since all my tests return an empty list here (also when using FolderArchive). So at this point I only return any stream that contains the relativePath without knowing if this is a correct behavior.

The call is done like this:
MemoryArchive memoryArchive = new MemoryArchive();
Map<?, ?> properties = new HashMap<Object, Object>();
IReportDocument reportDocument = getReportEngine().openReportDocument(memoryArchive.getName(), memoryArchive, properties);
With this attached the source code. Do with it whatever you like. If you run into problems using it, or if it is just running fine, I would appreciate you feedback. Thank you!