通过七牛的文档转化服务“亿方云文档转换”获取ppt的页数
java代码:
//输入ppt完整路径
//返回ppt页数
public Integer getPages(String url){
String path = url + "?yifangyun_preview/v2/action=get_page_count";
BufferedReader br = null;
try {
URL requestUrl = new URL(path);
br = new BufferedReader(new InputStreamReader(requestUrl.openStream()));
String pageResult = "";
String strTemp = "";
while (null != (strTemp = br.readLine())) {
pageResult = pageResult + strTemp;
}
if(!Utility.isEmptyString(pageResult)){
//返回json字符串
StringMap pageMap = Json.decode(pageResult);
return pageMap.get("page_count") != null?Integer.parseUnsignedInt((String) pageMap.get("page_count")):0;
}
} catch (Exception e) {
logger.error("qiniu get ppt pages error: ", e);
}finally {
try {
br.close();
} catch (IOException e) {
}
}
return 0;
}