use of mom.trd.opentheso.core.exports.helper.ExportStatistiques in project opentheso by miledrousset.
the class BaseDeDonnesBean method pdf.
/**
* permet de generer une document pour pouvoir le telecharger
* le format c'est pdf
* @return
* @throws SQLException
* @throws Exception
*/
public StreamedContent pdf() throws SQLException, Exception {
Thesaurus thesaurus = new Thesaurus();
ExportStatistiques expo = new ExportStatistiques();
expo.recuperatefils(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), theso.getThesaurus().getLanguage(), 2);
Document pdf = new Document(PageSize.LETTER);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter writer;
Paragraph para = new Paragraph(expo.getDocument());
writer = PdfWriter.getInstance(pdf, baos);
if (!pdf.isOpen()) {
pdf.open();
}
pdf.addTitle("theso");
pdf.add(para);
// Adding content to pdf
pdf.close();
InputStream stream = new ByteArrayInputStream(baos.toByteArray());
fileDownload = new DefaultStreamedContent(stream, "application/pdf", "Thésaurus" + thesaurus.getId_thesaurus() + ".pdf");
return fileDownload;
}
use of mom.trd.opentheso.core.exports.helper.ExportStatistiques in project opentheso by miledrousset.
the class BaseDeDonnesBean method genererdocument.
/**
* permet de generer une document pour pouvoir le telecharger
* le format c'est xml
* @return
* @throws SQLException
*/
public StreamedContent genererdocument() throws SQLException {
remplirText();
ExportStatistiques expo = new ExportStatistiques();
envoytext(expo);
expo.recuperatefils(connect.getPoolConnexion(), theso.getThesaurus().getId_thesaurus(), theso.getThesaurus().getLanguage(), 1);
InputStream stream;
java.util.Date datetoday = new java.util.Date();
try {
stream = new ByteArrayInputStream(expo.getDocument().getBytes("UTF-8"));
file = new DefaultStreamedContent(stream, "application/xml", "export " + theso.getThesaurus().getId_thesaurus() + datetoday + ".txt");
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(DownloadBean.class.getName()).log(Level.SEVERE, null, ex);
}
return file;
}
Aggregations