Hi all,
I am running this code: try{ String content = "This is a text"; File file = new File("file.adoc"); if (!file.exists()) { file.createNewFile(); } FileWriter fw = new FileWriter(file.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); bw.write(content); bw.close(); Asciidoctor asciidoctor = Asciidoctor.Factory.create(); HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put("backend", "pdf"); HashMap<String, Object> options = new HashMap<String, Object>(); options.put("attributes", attributes); options.put("in_place", true); String html = asciidoctor.convertFile(file,options); System.out.println(html); System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } but without a success. The error is appearing: org.jruby.exceptions.RaiseException: (RuntimeError) asciidoctor: FAILED: missing converter for backend 'pdf'. Processing aborted. at RUBY.convert(/home/amra/Documents/Diplomski/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Proba/WEB-INF/lib/asciidoctorj-1.5.2.jar!/gems/asciidoctor-1.5.2/lib/asciidoctor/document.rb:1016) at RUBY.convert(/home/amra/Documents/Diplomski/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Proba/WEB-INF/lib/asciidoctorj-1.5.2.jar!/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1499) at RUBY.convert_file(/home/amra/Documents/Diplomski/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Proba/WEB-INF/lib/asciidoctorj-1.5.2.jar!/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1562) at RUBY.convertFile(<script>:68) at org.jruby.gen.InterfaceImpl2102387735.convertFile(org/jruby/gen/InterfaceImpl2102387735.gen:13) I have already added asciidoctorj-pdf-1.5.0-alpha.9.jar or asciidoctorj-pdf-1.5.0-alpha.6.jar to the classpath but the error is still there. Converting to html is is running. I am using Vaadin with AsciidoctorJ. Thank you very much for your help. |
Administrator
|
The problem is that you are defining the backend using an attribute rather than an option. You almost always want to specify the backend as an option. That's the scenario that triggers the automatic loading of Asciidoctor PDF from within AsciidoctorJ. options.put("backend", "pdf") I tested this out and it will work. (I'm going to open an issue to get this recommendation added to the README). You may also want to consider using the typed interface for declaring options. See https://github.com/asciidoctor/asciidoctorj#conversion-options For reference, here's the code in AsciidoctorJ that automatically loads Asciidoctor PDF. |
Free forum by Nabble | Edit this page |