Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Creating a custom Report Item
jcwilson
I would like to create a new Report Item that allows me to embed files from URLs, File Systems and Data Source/Result Sets and even the output from other BIRT reports. The idea here is that a record in the database has associated links to documents that I would like to render and embed at the end of my report in an "Attachment (X...)" area. The document types could be images, MS Word, MS Excel, PDFs, etc. I am not looking for a way to access/read the files as I know each one needs its own library with the code specific to the file type. What I am looking for is guidance on the best way to implement this. Are there any examples that already do part of the job like opening a file and reading it?
Thanks,
John
Find more posts tagged with
Comments
georgeh12
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101648" data-time="1338837718" data-date="04 June 2012 - 12:21 PM"><p>
I would like to create a new Report Item that allows me to embed files from URLs, File Systems and Data Source/Result Sets and even the output from other BIRT reports. The idea here is that a record in the database has associated links to documents that I would like to render and embed at the end of my report in an "Attachment (X...)" area. The document types could be images, MS Word, MS Excel, PDFs, etc. I am not looking for a way to access/read the files as I know each one needs its own library with the code specific to the file type. What I am looking for is guidance on the best way to implement this. Are there any examples that already do part of the job like opening a file and reading it?<br /></p></blockquote>
<br />
Without doing any programming, try opening up a Text object and setting the Content Type to HTML. Include the following html:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><iframe style='height:500;width:500' src='http://www.birt-exchange.org'/></pre>
jcwilson
<blockquote class='ipsBlockquote' data-author="'georgeh12'" data-cid="101654" data-time="1338850580" data-date="04 June 2012 - 03:56 PM"><p>
Without doing any programming, try opening up a Text object and setting the Content Type to HTML. Include the following html:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'><iframe style='height:500;width:500' src='http://www.birt-exchange.org'/></pre></p></blockquote>
<br />
I appreciate the advice but I'm not looking for a gimmick that appears to address my need without actually doing anything.<br />
I should have included the additional need to render the output through all standard emitters and have the content appear as it should.<br />
<br />
John
georgeh12
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101658" data-time="1338851905" data-date="04 June 2012 - 04:18 PM"><p>
I should have included the additional need to render the output through all standard emitters and have the content appear as it should.<br /></p></blockquote>
I see, so you are looking for more information on rendering files through a custom emitter? <a class='bbc_url' href='
http://digiassn.blogspot.com/2007/08/birt-writing-emitter.html'>Here
is a blog</a> explaining how to write such a thing. Whether you end up using an iframe or custom object, you can use the emitter to output those "attachments" however you want. Since MS Office files are XML, it shouldn't be too hard to embed this attachment in Word or Excel.<br />
<br />
As far as previous projects on this subject, <a class='bbc_url' href='
http://google.com'>google</a>
.
jcwilson
<blockquote class='ipsBlockquote' data-author="'georgeh12'" data-cid="101660" data-time="1338854506" data-date="04 June 2012 - 05:01 PM"><p>
I see, so you are looking for more information on rendering files through a custom emitter? <a class='bbc_url' href='
http://digiassn.blogspot.com/2007/08/birt-writing-emitter.html'>Here
is a blog</a> explaining how to write such a thing. Whether you end up using an iframe or custom object, you can use the emitter to output those "attachments" however you want. Since MS Office files are XML, it shouldn't be too hard to embed this attachment in Word or Excel.<br />
<br />
As far as previous projects on this subject, <a class='bbc_url' href='
http://google.com'>google</a>.<br
/></p></blockquote>
<br />
I thought emitters came into play after the binary report object had been generated. Are you suggesting that an emitter could be used to render and stage portions of the binary report object? If so, I haven't seen any example of this type of emitter usage. Also, assuming this would work, how would one address the file open/read/process activities that must preseed the emitter calls?<br />
<br />
Thanks,<br />
John
georgeh12
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101662" data-time="1338855640" data-date="04 June 2012 - 05:20 PM"><p>
I thought emitters came into play after the binary report object had been generated. Are you suggesting that an emitter could be used to render and stage portions of the binary report object?<br /></p></blockquote>
The emitter can be used to render the report in any format (ie. MIME type, eg. html,xls). It uses Java to handle the "binary report objects", which are actually classes.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101662" data-time="1338855640" data-date="04 June 2012 - 05:20 PM"><p>
If so, I haven't seen any example of this type of emitter usage. Also, assuming this would work, how would one address the file open/read/process activities that must preseed the emitter calls?<br /></p></blockquote>
I have not tried fooling around with emitters myself, because they do take a good deal of personal effort. The file open/read/process is actually interpreting the XML in the rptdesign file. In BIRT these are relative to Prepare, Create, and Render events. The render process can be customized using the emitters. <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>This
graphic</a> shows when the render event occurs.
jcwilson
<blockquote class='ipsBlockquote' data-author="'georgeh12'" data-cid="101883" data-time="1338912396" data-date="05 June 2012 - 09:06 AM"><p>
The emitter can be used to render the report in any format (ie. MIME type, eg. html,xls). It uses Java to handle the "binary report objects", which are actually classes.<br />
<br />
<br />
I have not tried fooling around with emitters myself, because they do take a good deal of personal effort. The file open/read/process is actually interpreting the XML in the rptdesign file. In BIRT these are relative to Prepare, Create, and Render events. The render process can be customized using the emitters. <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>This
graphic</a> shows when the render event occurs.<br /></p></blockquote>
<br />
I do appreciate the advice I think you are trying to provide here. I just have a hard time envisioning an emitter being used several times within the initial generation of the report and then a final time at the end to produce the intended output.<br />
<br />
The emitter needs to have something to emit. What I am looking for, for example, is to open a pdf document, strip out the meta data and embed just the visible portions of the pdf file into the report. Just how can the emitter do that?
georgeh12
It seems what you really want to do is mash an attachment report onto the bottom of your BIRT report. This might be easier accomplished by building multiple BIRT reports with their respective attachments. What I suggest below will take a good deal of work to make a dynamic solution, and overcome a small amount of manual effort.<br />
<br />
An alternative idea might be to dynamically show/hide your imported report elements in the BIRT report. That way, a user clicks on one report, then chooses parameters to add attachments to the report.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101903" data-time="1338924133" data-date="05 June 2012 - 12:22 PM"><p>
I do appreciate the advice I think you are trying to provide here. I just have a hard time envisioning an emitter being used several times within the initial generation of the report and then a final time at the end to produce the intended output.<br /></p></blockquote>
The emitter is only used in the "presentation" phase for the object Render event.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'jcwilson'" data-cid="101903" data-time="1338924133" data-date="05 June 2012 - 12:22 PM"><p>
The emitter needs to have something to emit. What I am looking for, for example, is to open a pdf document, strip out the meta data and embed just the visible portions of the pdf file into the report. Just how can the emitter do that?<br /></p></blockquote>
In your example, the emitter would have to read the attachment object (eg. Text object) and get the document URI (eg. the iframe src attribute). Then the emitter would have to load the attachment, and I am sure there are plenty of Java classes to parse PDF files. After parsing the attachment, the emitter will output XML or HTML depending on your desired output format.
jcwilson
<blockquote class='ipsBlockquote' data-author="'georgeh12'" data-cid="101907" data-time="1338928142" data-date="05 June 2012 - 01:29 PM"><p>
It seems what you really want to do is mash an attachment report onto the bottom of your BIRT report. This might be easier accomplished by building multiple BIRT reports with their respective attachments. What I suggest below will take a good deal of work to make a dynamic solution, and overcome a small amount of manual effort.<br />
<br />
An alternative idea might be to dynamically show/hide your imported report elements in the BIRT report. That way, a user clicks on one report, then chooses parameters to add attachments to the report.<br />
<br />
<br />
The emitter is only used in the "presentation" phase for the object Render event.<br />
<br />
<br />
In your example, the emitter would have to read the attachment object (eg. Text object) and get the document URI (eg. the iframe src attribute). Then the emitter would have to load the attachment, and I am sure there are plenty of Java classes to parse PDF files. After parsing the attachment, the emitter will output XML or HTML depending on your desired output format.<br /></p></blockquote>
<br />
<br />
So, what you are suggesting would require customizing every emitter and add in the exact same code that loads, parses and embeds attachments?<br />
<br />
What I was looking for is to have all the attachments already embedded in the binary report object before any emitter comes into play. The end users should not have to do anything except run the report. So not secondary clicks or submits. This is because many times, these reports will be run in silent batches and sent directly to the printer.
CBR
If you are using a custom report item you are facing one problem...except that it should work in my opinion:
If you go with a custom report item the output will appear at exactly that position in the output. There is no way to tell BIRT that the element prefers to be rendered at the end of the report, while you put your report item on top of it in design phase. Each report item can decide about it's presentation so you can have:
OUTPUT_AS_CUSTOM
OUTPUT_AS_DRAWING
OUTPUT_AS_HTML_TEXT
OUTPUT_AS_IMAGE
OUTPUT_AS_IMAGE_WITH_MAP
OUTPUT_AS_TEXT
OUTPUT_NONE
I m not sure about the difference between Drawing and Image and i do not know what custom means. Each emitter will ask the element about its output type before rendering and it will then decide what to do with that element in your report (e.g. Excel will just skip every element having output type image).
So i m quite optimistic that you can have a generic element that just adds some other file content somewhere in your report, as long as you can live with the fact that it will just appear at the same place as the custom element in your report design.
jcwilson
If I put the custom item in the footer section of the report, then they will be at the end. I plan on dynamically adding these items through scripting based on the number of attachments. That way, they will appear at the end of the report.