Hi All,
I have set panels as below
First Panel-Personal Details
Second Panel-Educational Details
Third Panel-Family Details
Fourth Panel-Address Details.
My requirement is I have a PDF button on the UI, when I click on it, it should export all the panels data to a PDF file.
Note: I had look at <p:dataTable>to export the data to a PDF. But my UI doesn't have any <p:dataTable> components.My UI has only Panels.
Can you please help us in exporting these panels data to PDF?
Thanks & Regards,
Ravi Boreddy
How to export screen content to a PDF?
Try to handle your own stream with p:fileDownload, placed in our showcase;
http://www.primefaces.org/showcase-labs ... wnload.jsf
http://www.primefaces.org/showcase-labs ... wnload.jsf
PrimeFaces Team Member
Hi, Any simple example on how to convert the panel content to InputStream?
I did the following:
In the view:
In the Bean HomeBean.java:
Obviously, I am missing something simple here. How to create the stream from the panel component? The panel component on the view is bound to the Bean and I have the ptpListPanel in the getFile() method. How to convert it to pdf? Any pointers are highly appreciated.
Do I need to have the iText jar in my classpath?
Thanks!
I did the following:
In the view:
Code: Select all
<p:panel id="ptpListPanel" style="width: 98%" binding="#{homeBean.ptpListPanel}">
//Components etc.
</p:panel>
<p:commandButton value="PDF Export" ajax="false">
<p:fileDownload value="#{homeBean.file}" />
</p:commandButton>
Code: Select all
private UIPanel ptpListPanel;
public void setPtpListPanel(UIPanel ptpListPanel) {
this.ptpListPanel = ptpListPanel;
}
public UIPanel getPtpListPanel() {
return ptpListPanel;
}
private StreamedContent file;
public StreamedContent getFile() {
file = new DefaultStreamedContent(new ByteArrayInputStream(ptpListPanel.toString().getBytes()), "pdf", "test.pdf");
return file;
}
Do I need to have the iText jar in my classpath?
Thanks!
you probably cannot convert pf components other than datatable to a pdf using the dataexporter kit.
as we all others have to do, i would suggest to:
-render (draw) your pdf with a java pdfapi like e.g. pdfbox or iText - it will allow you to plot your custom information (ie. fields of your backing beans) in a desired layout and format
-finally, like ironhide said, use p;filedownload to deliver the pdf binary content to the client browser
as we all others have to do, i would suggest to:
-render (draw) your pdf with a java pdfapi like e.g. pdfbox or iText - it will allow you to plot your custom information (ie. fields of your backing beans) in a desired layout and format
-finally, like ironhide said, use p;filedownload to deliver the pdf binary content to the client browser
Mojarra 2.1.28, PrimeFaces 3.3.1, Primefaces Extensions 0.7.0, libservlet3.1-java tomcat8, openjdk-8-jdk
-
- Information
-
Who is online
Users browsing this forum: No registered users and 70 guests