开发者

Printing in icefaces

I would like to print开发者_如何转开发 reports in icefaces, but could got find any proper method for it. Please guide me for implementation of the same in my project.


I've used the ice:outputResource tag to let the user download a PDF report file. The resource attribute of that tag should point a managed bean property that implements com.icesoft.faces.context.Resource.


after getting idea from JOTN I'm finally able to put it together.

We can use the outputresource tag to link to any type of resource, not only static ones but also dynamically generated files(on the fly).

Let us have a look at the following example:

JSF Page:

..
..
<ice:outputResource id="outputResource1" attachment="false" fileName="File1.pdf" label="Click to download attachment" mimeType="application/pdf" rendered="true" resource="#{ReportParam01.reportfilers}" shared="false"/>
..
..

Here I've observed that the outputresource link won't appear until the file is actually generated(i case of on the fly documents).

Let us assume we wish to generate a pdf file dynamically. The following steps will link it to the above mentioned outputrespurce.

Managed Bean:

public class....{
     ....
     // This is the resource linked to the <ice:outputresource> tag.
     // Encapsulation has been done to link it.
     Reource reportfilers; 
     ....

     public void createDocument() {
         Document reportDoc = new Document(PageSize.A4);
         File file1 = new File("Report.pdf");
         PdfWriter.getInstance(reportDoc, new FileOutputStream(f));
         // writing to pdf code continues
         reportfilers = new FileResource(file1);
     }
     ....
     ....
}

Calling the above method (if it has no exceptions) will make the link to show up and the user can download the file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜