Search in sources :

Example 6 with WindowControlMocker

use of org.olat.core.gui.util.WindowControlMocker 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

Component (org.olat.core.gui.components.Component)6 WindowControl (org.olat.core.gui.control.WindowControl)6 WindowControlMocker (org.olat.core.gui.util.WindowControlMocker)6 File (java.io.File)4 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 CommentAndRatingSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback)2 UserCommentsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsController)2 Controller (org.olat.core.gui.control.Controller)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 FileResourceManager (org.olat.fileresource.FileResourceManager)2 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)2 AssessmentResultController (org.olat.ims.qti21.ui.AssessmentResultController)2 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)2 BinderOnePageController (org.olat.modules.portfolio.ui.BinderOnePageController)2 PageMetadataController (org.olat.modules.portfolio.ui.PageMetadataController)2 PageController (org.olat.modules.portfolio.ui.editor.PageController)2