Simplify PDF generation from DocBook
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 13 May 2022 06:24:43 +0000 (08:24 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 13 May 2022 06:24:43 +0000 (08:24 +0200)
org.argeo.app.servlet.publish/src/org/argeo/app/servlet/publish/DbkServlet.java

index f1d26760b104ec20f0c35eb34f1e95bb64975d72..d3459cf73a6514446cb9d4491a6095bf70784505 100644 (file)
@@ -143,23 +143,29 @@ public class DbkServlet extends HttpServlet {
                                                        FopFactory fopFactory = FopFactory.newInstance(URI.create(req.getRequestURL().toString()));
                                                        resp.setContentType("application/pdf");
 
-                                                       // DocBook to FO
-                                                       byte[] foBytes;
-                                                       try (ByteArrayOutputStream out = new ByteArrayOutputStream();) {
-                                                               Result xmlOutput = new StreamResult(out);
-                                                               Transformer docBookTransformer = docBoookFoTemplates.newTransformer();
-                                                               docBookTransformer.transform(xmlInput, xmlOutput);
-                                                               foBytes = out.toByteArray();
-                                                       }
-
-                                                       // FO to PDF
-                                                       try (InputStream foIn = new ByteArrayInputStream(foBytes)) {
-                                                               Fop fop = fopFactory.newFop("application/pdf", resp.getOutputStream());
-                                                               Transformer fopTransformer = transformerFactory.newTransformer(); // identity
-                                                               Source src = new StreamSource(foIn);
-                                                               Result fopResult = new SAXResult(fop.getDefaultHandler());
-                                                               fopTransformer.transform(src, fopResult);
-                                                       }
+//                                                     // DocBook to FO
+//                                                     byte[] foBytes;
+//                                                     try (ByteArrayOutputStream out = new ByteArrayOutputStream();) {
+//                                                             Result xmlOutput = new StreamResult(out);
+//                                                             Transformer docBookTransformer = docBoookFoTemplates.newTransformer();
+//                                                             docBookTransformer.transform(xmlInput, xmlOutput);
+//                                                             foBytes = out.toByteArray();
+//                                                     }
+//
+//                                                     // FO to PDF
+//                                                     try (InputStream foIn = new ByteArrayInputStream(foBytes)) {
+//                                                             Fop fop = fopFactory.newFop("application/pdf", resp.getOutputStream());
+//                                                             Transformer fopTransformer = transformerFactory.newTransformer(); // identity
+//                                                             Source src = new StreamSource(foIn);
+//                                                             Result fopResult = new SAXResult(fop.getDefaultHandler());
+//                                                             fopTransformer.transform(src, fopResult);
+//                                                     }
+//
+                                                       
+                                                       Fop fop = fopFactory.newFop("application/pdf", resp.getOutputStream());
+                                                       Transformer docBookTransformer = docBoookFoTemplates.newTransformer();
+                                                       Result fopResult = new SAXResult(fop.getDefaultHandler());
+                                                       docBookTransformer.transform(xmlInput, fopResult);
 
                                                } else {
                                                        Result xmlOutput = new StreamResult(resp.getOutputStream());