Java pdfbox提取的文本包含奇怪的问号符号,而不是空格
当我尝试使用ApachePDFBOx2.0.18从PDF中提取文本时,输出如下所示 我怎样才能避免那些问号符号? 下面是我的pdf提取方法Java pdfbox提取的文本包含奇怪的问号符号,而不是空格,java,pdfbox,Java,Pdfbox,当我尝试使用ApachePDFBOx2.0.18从PDF中提取文本时,输出如下所示 我怎样才能避免那些问号符号? 下面是我的pdf提取方法 public static String getPDFContent(File pdfFile) throws IOException { PDDocument doc = null; String text = null; try { doc = PDDocument.load(pdfFile);
public static String getPDFContent(File pdfFile) throws IOException {
PDDocument doc = null;
String text = null;
try {
doc = PDDocument.load(pdfFile);
text = new PDFTextStripper().getText(doc);
}
catch (Exception e) {
logger.error("An exception occurred while extracting text from pdf using Apache PDFBox.");
return null;
}
finally {
if( doc != null )
{
doc.close();
}
}
return text;
}
请分享有问题的PDF。此外,您如何输出字符串并获取这些符号?请阅读有关文本提取的常见问题解答:该链接完全没有帮助