/** * Gets report file. * * @return the report file */ @Nonnull public File getReportFile() { return new File(getRoot(), getName() + ".md"); }
/** * Gets report file. * * @return the report file */ @Nonnull public File getReportFile() { return new File(getRoot(), getName() + ".md"); }
private synchronized File writePdf(MutableDataSet options, File htmlFile) throws IOException { File root = getRoot(); CharSequence baseName = getName(); try (FileOutputStream out = new FileOutputStream(new File(root, baseName + ".pdf"))) { PdfConverterExtension.exportToPdf(out, FileUtils.readFileToString(htmlFile, "UTF-8"), htmlFile.getAbsoluteFile().toURI().toString(), options); } return new File(htmlFile.getPath().replaceAll("\\.html$", ".pdf")); }
private synchronized File writePdf(MutableDataSet options, File htmlFile) throws IOException { File root = getRoot(); CharSequence baseName = getName(); try (FileOutputStream out = new FileOutputStream(new File(root, baseName + ".pdf"))) { PdfConverterExtension.exportToPdf(out, FileUtils.readFileToString(htmlFile, "UTF-8"), htmlFile.getAbsoluteFile().toURI().toString(), options); } return new File(htmlFile.getPath().replaceAll("\\.html$", ".pdf")); }
@javax.annotation.Nonnull @Override public String png(@Nullable final BufferedImage rawImage, final CharSequence caption) { if (null == rawImage) return ""; @Nonnull final File file = pngFile(rawImage, new File(getResourceDir(), getName() + "." + ++MarkdownNotebookOutput.imageNumber + ".png")); return anchor(anchorId()) + "![" + caption + "](etc/" + file.getName() + ")"; }
@javax.annotation.Nonnull @Override public String jpg(@Nullable final BufferedImage rawImage, final CharSequence caption) { if (null == rawImage) return ""; @Nonnull final File file = jpgFile(rawImage, new File(getResourceDir(), getName() + "." + ++MarkdownNotebookOutput.imageNumber + ".jpg")); return anchor(anchorId()) + "![" + caption + "](etc/" + file.getName() + ")"; }
@javax.annotation.Nonnull @Override public String png(@Nullable final BufferedImage rawImage, final CharSequence caption) { if (null == rawImage) return ""; @Nonnull final File file = pngFile(rawImage, new File(getResourceDir(), getName() + "." + ++MarkdownNotebookOutput.imageNumber + ".png")); return anchor(anchorId()) + "![" + caption + "](etc/" + file.getName() + ")"; }
@javax.annotation.Nonnull @Override public String jpg(@Nullable final BufferedImage rawImage, final CharSequence caption) { if (null == rawImage) return ""; @Nonnull final File file = jpgFile(rawImage, new File(getResourceDir(), getName() + "." + ++MarkdownNotebookOutput.imageNumber + ".jpg")); return anchor(anchorId()) + "![" + caption + "](etc/" + file.getName() + ")"; }
@Override public void close() throws IOException { if (null != primaryOut) { primaryOut.close(); } try (@javax.annotation.Nonnull PrintWriter out = new PrintWriter(new FileOutputStream(getReportFile()))) { write(out); } File root = getRoot(); write(); writeZip(root, getName().toString()); onComplete.stream().forEach(fn -> { try { fn.run(); } catch (Throwable e) { log.info("Error closing log", e); } }); }
@Override public void close() throws IOException { if (null != primaryOut) { primaryOut.close(); } try (@javax.annotation.Nonnull PrintWriter out = new PrintWriter(new FileOutputStream(getReportFile()))) { write(out); } File root = getRoot(); write(); writeZip(root, getName().toString()); onComplete.stream().forEach(fn -> { try { fn.run(); } catch (Throwable e) { log.info("Error closing log", e); } }); }
setCurrentHome(root.toURI()); setArchiveHome(root.toURI()); primaryOut = new PrintStream(new FileOutputStream(new File(root, getName().toString()))); FileNanoHTTPD httpd = httpPort <= 0 ? null : new FileNanoHTTPD(root, httpPort); if (null != httpd) httpd.addGET("", "text/html", out -> { try { write(); try (FileInputStream input = new FileInputStream(new File(getRoot(), getName() + ".html"))) { IOUtils.copy(input, out); try { write(); try (FileInputStream input = new FileInputStream(new File(getRoot(), getName() + ".pdf"))) { IOUtils.copy(input, out); }); this.setAutobrowse(autobrowse); log.info(String.format("Serving %s/%s at http://localhost:%d", root.getAbsoluteFile(), getName(), httpPort)); if (null != httpd) { try { onComplete(() -> { try { if (isAutobrowse()) Desktop.getDesktop().browse(new File(getRoot(), getName() + ".html").toURI()); } catch (IOException e) { throw new RuntimeException(e);
setCurrentHome(root.toURI()); setArchiveHome(root.toURI()); primaryOut = new PrintStream(new FileOutputStream(new File(root, getName().toString()))); FileNanoHTTPD httpd = httpPort <= 0 ? null : new FileNanoHTTPD(root, httpPort); if (null != httpd) httpd.addGET("", "text/html", out -> { try { write(); try (FileInputStream input = new FileInputStream(new File(getRoot(), getName() + ".html"))) { IOUtils.copy(input, out); try { write(); try (FileInputStream input = new FileInputStream(new File(getRoot(), getName() + ".pdf"))) { IOUtils.copy(input, out); }); this.setAutobrowse(autobrowse); log.info(String.format("Serving %s/%s at http://localhost:%d", root.getAbsoluteFile(), getName(), httpPort)); if (null != httpd) { try { onComplete(() -> { try { if (isAutobrowse()) Desktop.getDesktop().browse(new File(getRoot(), getName() + ".html").toURI()); } catch (IOException e) { throw new RuntimeException(e);
@Override public <T> T subreport(String subreportName, Function<NotebookOutput, T> fn) { String reportName = getName() + subreportName; MarkdownNotebookOutput outer = this; try { try { subreport.write(); try (FileInputStream input = new FileInputStream(new File(root, subreport.getName() + ".html"))) { IOUtils.copy(input, out); try { subreport.write(); try (FileInputStream input = new FileInputStream(new File(root, subreport.getName() + ".pdf"))) { IOUtils.copy(input, out);
@Override public <T> T subreport(String subreportName, Function<NotebookOutput, T> fn) { if (null == subreportName) return subreport("", fn); String reportName = getName() + subreportName; MarkdownNotebookOutput outer = this; try { try { subreport.write(); try (FileInputStream input = new FileInputStream(new File(root, subreport.getName() + ".html"))) { IOUtils.copy(input, out); try { subreport.write(); try (FileInputStream input = new FileInputStream(new File(root, subreport.getName() + ".pdf"))) { IOUtils.copy(input, out);
private synchronized File writeHtml(MutableDataSet options) throws IOException { List<Extension> extensions = Arrays.asList( TablesExtension.create(), SubscriptExtension.create(), EscapedCharacterExtension.create() ); Parser parser = Parser.builder(options).extensions(extensions).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).extensions(extensions).escapeHtml(false).indentSize(2).softBreak("\n").build(); String txt = toString(toc) + "\n\n" + toString(markdownData); FileUtils.write(new File(getRoot(), getName() + ".md"), txt, "UTF-8"); File htmlFile = new File(getRoot(), getName() + ".html"); String html = renderer.render(parser.parse(txt)); html = "<html><body>" + html + "</body></html>"; try (FileOutputStream out = new FileOutputStream(htmlFile)) { IOUtils.write(html, out, Charset.forName("UTF-8")); } log.info("Wrote " + htmlFile); // log.info("Wrote " + htmlFile); // return htmlFile; }
private synchronized File writeHtml(MutableDataSet options) throws IOException { List<Extension> extensions = Arrays.asList( TablesExtension.create(), SubscriptExtension.create(), EscapedCharacterExtension.create() ); Parser parser = Parser.builder(options).extensions(extensions).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).extensions(extensions).escapeHtml(false).indentSize(2).softBreak("\n").build(); String txt = toString(toc) + "\n\n" + toString(markdownData); FileUtils.write(new File(getRoot(), getName() + ".md"), txt, "UTF-8"); File htmlFile = new File(getRoot(), getName() + ".html"); String html = renderer.render(parser.parse(txt)); html = "<html><body>" + html + "</body></html>"; try (FileOutputStream out = new FileOutputStream(htmlFile)) { IOUtils.write(html, out, Charset.forName("UTF-8")); } log.info("Wrote " + htmlFile); // log.info("Wrote " + htmlFile); // return htmlFile; }