| | |
| | | String fname = nameext.substring(0, nameext.lastIndexOf(DOT)); |
| | | File htmlfile = new File(adocfile.getParentFile(), fname + DOT + HTML); |
| | | File outfile = htmlfile; // Standardmaessig wird HTML zurueckgegeben |
| | | response.setContentType("text/html;charset=UTF-8"); |
| | | |
| | | response.setCharacterEncoding("UTF-8"); |
| | | |
| | | /* |
| | | nach HTML transformieren, wenn die Quelle sich geandert hat oder |
| | | die HTML-Datei noch nicht existiert |
| | |
| | | if(null != pdf && pdf.equalsIgnoreCase(Boolean.TRUE.toString())) { |
| | | File pdffile = new File(adocfile.getParentFile(), fname + DOT + PDF); |
| | | outfile = pdffile; // PDF soll zurueckgegeben werden |
| | | response.setContentType("application/pdf;charset=UTF-8"); |
| | | if(!pdffile.exists() || adocfile.lastModified() > pdffile.lastModified()) { |
| | | response.setContentType("application/pdf"); |
| | | transform(absname, PDF); |
| | | } |
| | | } |
| | |
| | | try (PrintWriter out = response.getWriter()) { |
| | | // abhaengig vom Parameter pdf HTML- oder PDF-Datei ausgeben |
| | | FileInputStream in = new FileInputStream(outfile); |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(in)); |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | out.println(line); |
| | |
| | | * nach PDF transformiert werden soll |
| | | */ |
| | | private void transform(String fileName, String backend) { |
| | | Map<String, Object> attributes = attributes() |
| | | .sourceHighlighter("highlightjs") |
| | | .asMap(); |
| | | Map<String, Object> attributes; |
| | | File outFile = new File(fileName); |
| | | String thisDirName = outFile.getParent(); |
| | | File pdfStyles = new File(outFile.getParentFile(), "custom-theme.yml"); |
| | | if(pdfStyles.exists()) { |
| | | attributes = attributes() |
| | | .attribute("pdf-themesdir", thisDirName) |
| | | .attribute("pdf-theme","custom") |
| | | .attribute("pdf-fontsdir", thisDirName + "/fonts") |
| | | .attribute("allow-uri-read") |
| | | .sourceHighlighter("highlightjs") |
| | | .asMap(); |
| | | } else { |
| | | attributes = attributes() |
| | | .sourceHighlighter("highlightjs") |
| | | .asMap(); |
| | | } |
| | | Map<String, Object> options; |
| | | if(null != backend) { |
| | | options = options() |
| | | .inPlace(false) |
| | | .backend(backend) |
| | | .attributes(attributes) |
| | | .asMap(); |
| | | options = options().inPlace(false) |
| | | .backend(backend).attributes(attributes).asMap(); |
| | | |
| | | } else { |
| | | options = options() |
| | | .inPlace(false) |
| | | .attributes(attributes) |
| | | .asMap(); |
| | | options = options().inPlace(false) |
| | | .attributes(attributes).asMap(); |
| | | } |
| | | |
| | | Asciidoctor asciidoctor = create(); |
| | | asciidoctor.requireLibrary("asciidoctor-diagram"); |
| | | asciidoctor.convertFile(new File(fileName), options); |
| | | } |
| | | |