| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.PrintWriter; |
| | | import java.util.HashMap; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Map; |
| | | import javax.servlet.ServletOutputStream; |
| | | |
| | | import static org.asciidoctor.Asciidoctor.Factory.create; |
| | | import org.asciidoctor.Asciidoctor; |
| | |
| | | wenn die Quelle sich geandert hat oder |
| | | die PDF-Datei noch nicht existiert |
| | | */ |
| | | |
| | | String pdf = request.getParameter(PDF); |
| | | if(null != pdf && pdf.equalsIgnoreCase(Boolean.TRUE.toString())) { |
| | | File pdffile = new File(adocfile.getParentFile(), fname + DOT + PDF); |
| | |
| | | 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, "UTF-8")); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | out.println(line); |
| | | ServletOutputStream os = response.getOutputStream(); |
| | | InputStream bytes = new FileInputStream(outfile); |
| | | int b = bytes.read(); |
| | | while(b > -1 ) { |
| | | os.write(b); |
| | | b = bytes.read(); |
| | | } |
| | | } else { |
| | | PrintWriter out = response.getWriter(); |
| | | InputStreamReader in = new InputStreamReader(new FileInputStream(outfile), "UTF-8"); |
| | | in.transferTo(out); |
| | | } |
| | | } |
| | | |