Note that there are some explanatory texts on larger screens.

plurals
  1. POFOP for Android?
    text
    copied!<p>I recently compiled an Android app using FOP as I want to convert some XML into a PDF file. However I don't think the FOP JAR files are mean't to work on Android. Are there any versions of FOP available for Android? Or any other XML to PDF converter I could use within my app instead of connecting to a FOP enabled server on the Internet?</p> <p>I've tried including fop.jar and the xmlgraphics.jar but even with those added to my project, the call to <code>FopFactory.newInstance()</code> fails.</p> <p>Here's my code snippet for the button click that calls FOP:</p> <pre><code>// Add button listener btnCreatePDF.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FopFactory fopFactory = FopFactory.newInstance(); OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("/sdcard/test.pdf"))); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); Source src = new StreamSource(new File("/sdcard/test.fo")); Result res = new SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); out.close(); } });</code></pre> <p>The compiler is also giving a me a bunch of <code>Dxwarning: Ignoring InnerClasses attribute...</code> errors. Here's the error when I click the button to create the PDF:</p> <pre><code>02-22 14:16:23.641: WARN/System.err(5590): java.lang.UnsupportedOperationException: Don't know how to handle "application/pdf" as an output format. Neither an FOEventHandler, nor a Renderer could be found for this output format. 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:361) 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.fo.FOTreeBuilder.(FOTreeBuilder.java:105) 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:101) 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.apps.Fop.(Fop.java:79) 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:271) 02-22 14:16:23.641: WARN/System.err(5590): at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:248) 02-22 14:16:23.641: WARN/System.err(5590): at com.zebdor.signal88.ProposalCalculator$3.onClick(ProposalCalculator.java:158) 02-22 14:16:23.641: WARN/System.err(5590): at android.view.View.performClick(View.java:2501) 02-22 14:16:23.641: WARN/System.err(5590): at android.view.View$PerformClick.run(View.java:9107) 02-22 14:16:23.641: WARN/System.err(5590): at android.os.Handler.handleCallback(Handler.java:587) 02-22 14:16:23.641: WARN/System.err(5590): at android.os.Handler.dispatchMessage(Handler.java:92) 02-22 14:16:23.641: WARN/System.err(5590): at android.os.Looper.loop(Looper.java:123) 02-22 14:16:23.641: WARN/System.err(5590): at android.app.ActivityThread.main(ActivityThread.java:3812) 02-22 14:16:23.641: WARN/System.err(5590): at java.lang.reflect.Method.invokeNative(Native Method) 02-22 14:16:23.641: WARN/System.err(5590): at java.lang.reflect.Method.invoke(Method.java:507) 02-22 14:16:23.641: WARN/System.err(5590): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 02-22 14:16:23.641: WARN/System.err(5590): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 02-22 14:16:23.641: WARN/System.err(5590): at dalvik.system.NativeStart.main(Native Method) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload