使用 Apache PDFBox 提取文本得到错误的字符?
Using Apache PDFBox for extracting text getting wrong charecters?
我正在尝试使用 Apache PDFBox 1.8.4 从 PDF 中提取文本 - 我的代码如下:
public static void main(String[] args) throws Exception {
PDDocument pdfDocument = PDDocument.load(new File("rep.pdf"));
PDFTextStripper stripper = new PDFTextStripper();
String s = stripper.getText(pdfDocument);
System.out.println(s);
pdfDocument.close();
}
要转换的pdf:https://www.dropbox.com/s/t35rr23v4383yvt/Form-V-report.pdf?dl=0
但得到了这样的字符:
!"#$%&'()*$+,)!'-,./+/
0+12)3$#'(,,)451#+('1)65+7(,+'(/
!"#$%&'(
)*+,-.##(',/$.0
123.4.5,67,,89:;+
<3$'(=,>:++?,*99%@AB)
有什么解决办法吗?
提前 - 谢谢。
Adobe 集成了 PDF 混淆功能,PDF 的创建者可以启用它。我不记得它是如何工作的,但如果您使用任何在线 PDF text-extraction 工具,或者如果您尝试复制和粘贴文本,您会发现类似的问题。
您可能需要:
A) 在未启用此功能的情况下索取副本
或
B) 需要逆向工程是如何完成的,并使用该知识来逆向它。
我感觉 A 是正确答案
我正在尝试使用 Apache PDFBox 1.8.4 从 PDF 中提取文本 - 我的代码如下:
public static void main(String[] args) throws Exception {
PDDocument pdfDocument = PDDocument.load(new File("rep.pdf"));
PDFTextStripper stripper = new PDFTextStripper();
String s = stripper.getText(pdfDocument);
System.out.println(s);
pdfDocument.close();
}
要转换的pdf:https://www.dropbox.com/s/t35rr23v4383yvt/Form-V-report.pdf?dl=0
但得到了这样的字符:
!"#$%&'()*$+,)!'-,./+/
0+12)3$#'(,,)451#+('1)65+7(,+'(/
!"#$%&'(
)*+,-.##(',/$.0
123.4.5,67,,89:;+
<3$'(=,>:++?,*99%@AB)
有什么解决办法吗?
提前 - 谢谢。
Adobe 集成了 PDF 混淆功能,PDF 的创建者可以启用它。我不记得它是如何工作的,但如果您使用任何在线 PDF text-extraction 工具,或者如果您尝试复制和粘贴文本,您会发现类似的问题。
您可能需要:
A) 在未启用此功能的情况下索取副本
或
B) 需要逆向工程是如何完成的,并使用该知识来逆向它。
我感觉 A 是正确答案