pdf가 많은 폴더가 있으므로이 파일을 모두 txt로 변환하고 해당 텍스트 파일을 다른 폴더에 저장해야합니다. 나는 이것을 위해 자바를 사용하고 싶다.여러 PDF 파일을 Java의 폴더에있는 텍스트로 파싱하는 방법
pdf를 구문 분석하는이 코드가 있지만 한 번에 하나씩 만 작동하므로 수천 개의 pdf가있는 폴더를 처리해야합니다.
PDFTextStripper pdfStripper = null;
PDDocument pdDoc = null;
COSDocument cosDoc = null;
File file = new File("C:/my.pdf");
try {
PDFParser parser = new PDFParser(new FileInputStream(file));
parser.parse();
cosDoc = parser.getDocument();
pdfStripper = new PDFTextStripper();
pdDoc = new PDDocument(cosDoc);
pdfStripper.setStartPage(1);
pdfStripper.setEndPage(20);
String parsedText = pdfStripper.getText(pdDoc);
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
아이디어가 있으십니까?
뭔가를 시도 할 수 있습니다. –
폴더 이름과 하나의 파일 이름 대신'listFiles()'메소드를 사용해보십시오 –