import com.suwell.ofd.custom.agent.HTTPAgent; import com.suwell.ofd.custom.wrapper.Const; import com.suwell.ofd.custom.wrapper.Packet; import com.suwell.ofd.custom.wrapper.model.Common; import com.suwell.ofd.custom.wrapper.model.Pair;
//链接上ofd转换的服务器 HTTPAgent ha = new HTTPAgent("ofdserviceurl"); Packet w = new Packet("merge.ofd2image", Const.Target.IMAGE); w.file(new Common(null, "ofd", input)); //传入的文件流(必须为ofd的输入流,要不然会报错) w.invoke(null, null, "MergeImage", //生成图片的类型(支持png、jpg、bmp) new Pair<String, String>("type", "jpg"), //生成图片的dpi new Pair<String, String>("dpi", "96"), //生成每张图片的页数 new Pair<String, String>("step", "3")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ha.convert(w, baos); //到此 亦可以转换成输入流进行写出 InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());