title: docx to png converter using docx4j
body: <p>while converting docx to png using docx4j getting UnsupportedOperationException . Below are the sample code.</p>
  
  <pre><code>public class DocToPng {
  public static void main(String[] args) throws Docx4JException, IOException {
      String inPath="D:\\pdfconverterfolder\\test.docx";
      String outPath="D:\\pdfconverterfolder\\pngOutput.png";
       File theFile = new File(inPath);
      File outile=new File(outPath);
      WordprocessingMLPackage wordMLPckg = Docx4J.load(theFile);
      OutputStream os = new FileOutputStream(outile);
      FOSettings settings = Docx4J.createFOSettings();
      settings.setWmlPackage(wordMLPckg);
      settings.setApacheFopMime("images/png");
      Docx4J.toFO(settings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
      os.close();
      System.out.println("DOne");
  }
  }
  </code></pre>
  
  <p>and below are the console output:</p>
  
  <pre><code>[main] INFO org.docx4j.org.apache.xml.serializer.ToXMLStream - Using repackaged ToXMLStream
  [main] INFO org.docx4j.org.apache.xml.serializer.ToXMLStream - Using repackaged ToXMLStream
  [main] ERROR org.docx4j.convert.out.common.AbstractExporter - Exception exporting package
  java.lang.UnsupportedOperationException: Don't know how to handle "images/png" as an output format. Neither an FOEventHandler, nor a Renderer could be found for this output format.
      at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:365)
      at org.apache.fop.fo.FOTreeBuilder.&lt;init&gt;(FOTreeBuilder.java:107)
      at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104)
      at org.apache.fop.apps.Fop.&lt;init&gt;(Fop.java:78)
      at org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:182)
      at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:219)
      at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:240)
      at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:187)
      at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)
      at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
      at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
      at org.docx4j.Docx4J.toFO(Docx4J.java:689)
      at toImage.DocToPng.main(DocToPng.java:26)
  Exception in thread "main" org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
      at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:109)
      at org.docx4j.Docx4J.toFO(Docx4J.java:689)
      at toImage.DocToPng.main(DocToPng.java:26)
  Caused by: java.lang.UnsupportedOperationException: Don't know how to handle "images/png" as an output format. Neither an FOEventHandler, nor a Renderer could be found for this output format.
      at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:365)
      at org.apache.fop.fo.FOTreeBuilder.&lt;init&gt;(FOTreeBuilder.java:107)
      at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104)
      at org.apache.fop.apps.Fop.&lt;init&gt;(Fop.java:78)
      at org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:182)
      at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:219)
      at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:240)
      at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:187)
      at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)
      at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
      at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
      ... 2 more
  </code></pre>
  
  <p>looks like docx4j doesn't support to convert into any image format.Any suggestion.? Thanks.!</p>