I am trying to convert a JSF Page to PDF with Flying Saucer.
In the rapport.xhtml I have some backing bean parameters, which values should appear in the pdf. But they do not. If I access the xhtml page, then values showing correctly, I can see the pdf page with pure text that I have written but not the backing bean values.
this is my function in the backing bean for converting :
public void createpdf() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext excontext = facesContext.getExternalContext();
HttpSession session = (HttpSession) excontext.getSession(true);
String url = "http://localhost:8080/digitalisation_lstp/chef/rapport.xhtml;jsessionid="+session.getId()+"?pdf=true";
try {
ITextRenderer renderer = new ITextRenderer();
//InputStream is = new URL(url).openStream();
renderer.setDocument(new URL(url).toString());
renderer.layout();
HttpServletResponse response = (HttpServletResponse) excontext.getResponse();
response.reset();
response.setContentType("application/pdf");
response.setHeader("content-Disposition", "inline: filename\"print-file.dpf\"");
OutputStream outputstream = response.getOutputStream();
renderer.createPDF(outputstream);
outputstream.close();
} catch (Exception e) {
}
facesContext.responseComplete();
}
And this is rapport.xhtml:
(the values I want to appear in the pdf)
<table style="" border="1">
<tr >
<td class="td1"> Dossier N </td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().num_dossier}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Client</td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().client}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Chantier</td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().chantier}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Prestation</td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().prestation}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Type de béton</td>
<td class="td2"> <h:outputText value="#{rapportCtlr.afficher_rapport().type_beton}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Lieu de pélèvement</td>
<td class="td2"> <h:outputText value="#{rapportCtlr.afficher_rapport().lieu_preleve}"></h:outputText></td>
</tr>
<tr>
<td class="td1">Rèf de rapport</td>
<td class="td2"> <h:outputText value="#{rapportCtlr.afficher_rapport().ref_rapport}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Date d'émission</td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().date_emission}"></h:outputText></td>
</tr>
<tr>
<td class="td1"> Date de prèlèvement</td>
<td class="td2"> <h:outputText value="#
{rapportCtlr.afficher_rapport().date_preleve}"></h:outputText></td>
</tr>
</table>
but values of are not being shown in pdf. Only the values of are shown.