如图, 测试过多个文档, 不同服务器环境, 好像跟环境有关
以下是代码:
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
int tempDlen = doc.getPageCount();
// log.info("tempDlen is" + tempDlen);
// System.out.println("tempDlen "+tempDlen);
ByteArrayOutputStream stream = null;
for (int k = 0; k < tempDlen; k++)
{
try
{
stream = new ByteArrayOutputStream();
PageSet ps = new PageSet(k);
saveOptions.setPageSet(ps);
doc.save(stream, saveOptions);
sb.append(stream2StrWithImg(stream));
}
catch (Exception e)
{
log.error("parseWord2Img error", e);
}
finally
{
if (stream != null)
{
try
{
stream.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
}