Programming using the BIRT Reporting APIs : Generating reports from an application : Opening a source for report generation : Understanding an IReportDocument object
 
Understanding an IReportDocument object
The IReportDocument object provides access to the structure and contents of a binary report document. IReportDocument provides methods to retrieve bookmark, page, and report design information. A bookmark is a String object that locates an instance of a report element in the document and the page on which the element exists. Use page information to render individual pages in the document to an output format. Bookmarks also provide access to the design elements that generated the element instance.
Use the getBookmarks( ) method to get a List object containing all the bookmarks in the document. Call the getBookmarkInstance( ) method with a String argument containing a bookmark to access the instantiated report element. Calling the getReportRunnable( ) method returns an IReportRunnable object, which an application can use to access report design information or generate another report document.
Close the document after use by calling IReportDocument.close( ).
How to access a report document
Listing 12‑5 shows how to open a report document and find a page. If the engine cannot open the specified report design, the code logs the error. The variable, engine, is a ReportEngine object.
Listing 12‑5 Accessing a report document
String dName = "./SimpleReport.rptdocument";
IReportDocument doc = null;
try {
doc = engine.openReportDocument( dName );
} catch ( EngineException e ) {
System.err.println( "Document " + dName + " not found!" );
return;
}
// Get the second bookmark in the document.
java.util.List bookmarks = doc.getBookmarks( );
String bookmark = ( String ) bookmarks.get( 1 );
long pageNumber = doc.getPageNumber( bookmark );
logger.log(Level.INFO, bookmark + " Page number: " + pageNumber);
// Close the document.
doc.close( );