【发布时间】:2014-11-06 10:43:21
【问题描述】:
我正在尝试获取僧伽罗语 pdf 的内容(例如:http://archives.dailynews.lk/2001/pix/GazetteS14-01-03.pdf)。
我将pdf保存在计算机中并使用了以下代码。
import java.io.IOException;
import com.snowtide.pdf.OutputTarget;
import com.snowtide.pdf.PDFTextStream;
public class ExtractTextAllPages {
public static void main (String[] args) throws IOException {
String pdfFilePath = "/home/chamila/semester7/fyp/gazette/GazetteS14-01-03.pdf";
PDFTextStream pdfts = new PDFTextStream(pdfFilePath);
StringBuilder text = new StringBuilder(1024);
pdfts.pipe(new OutputTarget(text));
pdfts.close();
System.out.printf("The text extracted from %s is:", pdfFilePath);
System.out.println(text);
}
}
但我得到的输出类似于以下内容。
Y%S ,xld m%cd;dka;%sl iudcjd§ ckrcfha .eiÜ m;%h 1
wxl 1"844 – 2014 ckjdß ui 03 jeks isl=rdod – 2014'01'03
^rcfha n,hmsg m%isoaO lrk ,§'&
I jeks fldgi : ^IIw& jeks fPoh - m<lsÍï
;k;=re - wenE3;=
Y%S ,xld fmd,sia fomd3;fïka;=j
.............................
这是什么原因?如何获取 pdf 中的确切内容?
【问题讨论】: