-
1. Re: Rendering PDF
lvdberg May 30, 2011 3:54 AM (in response to rafaelfrade)Hi,
Although the PDF-support ins Seam is great, nothing beats using the API's directly. It takes some effort, but the result is better.
In my opinion PDF is a bit to closely coupled, but that's something for another Thread.Look at the iText API, or use Birt/JasperReports. The latter has also a nice API to dynamically generate reports. In this way you create the report in the format you want and - if needed - you can output (stream) it directly to your user.
Leo
-
2. Re: Rendering PDF
cathyben Jul 28, 2015 11:10 PM (in response to rafaelfrade)I found a C#.net PDF rendering API. And it have related pdf reading and edition feature you wanted.
If you think it's helpful, you can have a look at it.
Best regards.
-
3. Re: Rendering PDF
baddeley84 Aug 4, 2015 10:24 AM (in response to rafaelfrade)You should be able to do this in Seam, I have done something similar to email an Excel document as an attachment, see code below, I am sure you could adapt this for Seam PDF
In the .xhtml file you need to set the export key, this places the generated document in the event scope...eg:
<e:workbook xmlns:e="http://jboss.org/schema/seam/excel" xmlns:f="http://java.sun.com/jsf/core" exportKey="_pue" filename="#{poolReportsActions.reportFileName}">
then the following backing bean code to retrieve the report as a byte array:
//Render the report using a fake request EmptyFacesContext emptyFacesContext = new EmptyFacesContext(); try { String pageLocation = "/somePage.xhtml"; Renderer renderer = Renderer.instance(); renderer.render(pageLocation) //Retrieve the report from the event context if(Contexts.getEventContext().get("_pue")!=null){ DocumentData data = (DocumentData) Contexts.getEventContext().get("_pue"); ByteArrayDocumentData byteData = null; if (data instanceof ByteArrayDocumentData) { byteData = (ByteArrayDocumentData) data; } else { throw new IllegalArgumentException("Couldnt get the bytes from the pdf document, unkown class " + data.getClass().getName()); } //Send email with attachement Map<String,Object> emailMap = new HashMap<String,Object>(); emailMap.put("clientUser", clientUser); emailService.sendMessageToUser(Email.client_usage_report, clientUser, emailMap); }else{ log.error("No document found"); } }catch(Exception ex){ log.error("Error when trying to get the content of the excel in bytes with the message:\n {0}", ExceptionUtils.getStackTrace(ex)); }finally{ emptyFacesContext.restore(); }