Search in sources :

Example 1 with BinderOnePageController

use of org.olat.modules.portfolio.ui.BinderOnePageController in project OpenOLAT by OpenOLAT.

the class ExportBinderAsPDFResource method prepareHtml.

private File prepareHtml() {
    File outputDir = new File(WebappHelper.getTmpDir(), "pf" + UUID.randomUUID());
    outputDir.mkdirs();
    WindowControl mockwControl = new WindowControlMocker();
    BinderOnePageController printCtrl;
    if (selectedPage != null) {
        printCtrl = new BinderOnePageController(ureq, mockwControl, selectedPage, ExtendedMediaRenderingHints.toPdf(), false);
    } else {
        printCtrl = new BinderOnePageController(ureq, mockwControl, binderRef, ExtendedMediaRenderingHints.toPdf(), false);
    }
    Component content = printCtrl.getInitialComponent();
    String html = createResultHTML(content);
    File indexHtml = new File(outputDir, "index.html");
    exportCSSAndJs(outputDir);
    html = exportMedia(html, outputDir);
    try (OutputStream out = new FileOutputStream(indexHtml)) {
        IOUtils.write(html, out, "UTF-8");
    } catch (IOException e) {
        log.error("", e);
    }
    printCtrl.dispose();
    return outputDir;
}
Also used : BinderOnePageController(org.olat.modules.portfolio.ui.BinderOnePageController) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) WindowControl(org.olat.core.gui.control.WindowControl) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Example 2 with BinderOnePageController

use of org.olat.modules.portfolio.ui.BinderOnePageController in project openolat by klemens.

the class ExportBinderAsPDFResource method prepareHtml.

private File prepareHtml() {
    File outputDir = new File(WebappHelper.getTmpDir(), "pf" + UUID.randomUUID());
    outputDir.mkdirs();
    WindowControl mockwControl = new WindowControlMocker();
    BinderOnePageController printCtrl;
    if (selectedPage != null) {
        printCtrl = new BinderOnePageController(ureq, mockwControl, selectedPage, ExtendedMediaRenderingHints.toPdf(), false);
    } else {
        printCtrl = new BinderOnePageController(ureq, mockwControl, binderRef, ExtendedMediaRenderingHints.toPdf(), false);
    }
    Component content = printCtrl.getInitialComponent();
    String html = createResultHTML(content);
    File indexHtml = new File(outputDir, "index.html");
    exportCSSAndJs(outputDir);
    html = exportMedia(html, outputDir);
    try (OutputStream out = new FileOutputStream(indexHtml)) {
        IOUtils.write(html, out, "UTF-8");
    } catch (IOException e) {
        log.error("", e);
    }
    printCtrl.dispose();
    return outputDir;
}
Also used : BinderOnePageController(org.olat.modules.portfolio.ui.BinderOnePageController) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) WindowControl(org.olat.core.gui.control.WindowControl) Component(org.olat.core.gui.components.Component) File(java.io.File) WindowControlMocker(org.olat.core.gui.util.WindowControlMocker)

Aggregations

File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Component (org.olat.core.gui.components.Component)2 WindowControl (org.olat.core.gui.control.WindowControl)2 WindowControlMocker (org.olat.core.gui.util.WindowControlMocker)2 BinderOnePageController (org.olat.modules.portfolio.ui.BinderOnePageController)2