我已经开始在我们的项目中创建一种新方法以返回总页数.我们正在使用TIFFTweaker,可从以下URL-https://github.com/dragon66/icafe/blob/master/src/com/icafe4j/image/tiff/TIFFTweaker.java进行引用
在此类中,我找到了TIFFTweaker.getPageCount()方法,该方法看起来像它的getPageCount()方法想要一个RandomAccessInputStream对象.
我一直在尝试从文件对象中获取他们想要的东西.
什么是最好的方法来解决这个问题,并从tiff返回总页数?
我看过一些Java文档,stackOverflow和一些随机博客,但似乎无法弄清楚如何从文件对象转换为randomaccessinputstream.
@Override
public Integer totalPages(File file) {
Integer numberOfPages = 0;
try{
//TIFFTweaker.getPageCount(); - How to pass the file and get the count? Problem is type is a random access input stream and I have a file type
FileInputStream fileInputStream = new FileInputStream(file);
String absolutePath = file.getAbsolutePath();
// return TIFFTweaker.getPageCount();
}catch(IOException e){
log.error("Error with Tiff File" + e);
}
return null;
}
我期望返回一个数值,该数值代表我正在传递的TIFF文件中的页面总数.