Search in sources :

Example 1 with ExportStatistiques

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;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) PdfWriter(com.itextpdf.text.pdf.PdfWriter) Thesaurus(mom.trd.opentheso.bdd.datas.Thesaurus) ByteArrayInputStream(java.io.ByteArrayInputStream) ExportStatistiques(mom.trd.opentheso.core.exports.helper.ExportStatistiques) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(com.itextpdf.text.Document) Paragraph(com.itextpdf.text.Paragraph)

Example 2 with ExportStatistiques

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;
}
Also used : DefaultStreamedContent(org.primefaces.model.DefaultStreamedContent) ByteArrayInputStream(java.io.ByteArrayInputStream) ExportStatistiques(mom.trd.opentheso.core.exports.helper.ExportStatistiques) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ExportStatistiques (mom.trd.opentheso.core.exports.helper.ExportStatistiques)2 DefaultStreamedContent (org.primefaces.model.DefaultStreamedContent)2 Document (com.itextpdf.text.Document)1 Paragraph (com.itextpdf.text.Paragraph)1 PdfWriter (com.itextpdf.text.pdf.PdfWriter)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Thesaurus (mom.trd.opentheso.bdd.datas.Thesaurus)1