Home
Analytics
Get IreportDocument
akao
Hi everybody !!!
I search How have an IreportDocument.
I want have my page number, and i saw that in a IReportDocument there is an getPageNumber() function.
Can you help me ?
Thanks
Find more posts tagged with
Comments
johnw
Your not really supposed to get access to the report document unless ou are using the report engine API for render tasks, retrieving individual pages from a report document, or rendering to different formats.
But, you can do it using Java reflection. The following example script, which needs to go into the beforeRender or afterRender events, will get you access to the report document in the context. Just replace the getName() method with getPageNumber(), and move to the onPageBreak() event. This value will only increase for renderings with page breaks.
var rcClass = reportContext.getClass();
var fieldFromScript = rcClass.getDeclaredField("context");
fieldFromScript.setAccessible(true);
var execContext = fieldFromScript.get(reportContext);
// Now, we have the exeuctionContext. We can get the currently rendering
// report documents location
var doc = execContext.getReportDocument();
var name = "Empty";
if (doc != null) {
name = doc.getName();
}
vcarton
reflection doesn't work. why ?
any idea ?