我尝试从大型 pdf 中提取文本,但我只得到第一页,我需要将所有文本传递给字符串变量。
这是代码
public class ParsePDF {
public static void main(String args[]) throws Exception {
try {
File file = new File("C:/vlarge.pdf");
String content = new Tika().parseToString(file);
System.out.println("The Content: " + content);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
最佳答案
来自Javadocs :
To avoid unpredictable excess memory use, the returned string contains only up to getMaxStringLength() first characters extracted from the input document. Use the setMaxStringLength(int) method to adjust this limitation.
调用 setMaxStringLength(-1)
将禁用此限制。
关于java - 使用 Tika 从大型 pdf 中提取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19074191/