Java code String getWord(String path) { System.out.println(); System.out.println(); File file File(path); String returnString ; InputStream is; try { is FileInputStream(file); WordExtractor extractor WordExtractor(); returnString = extractor.extractText(is); System.out.println(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return returnString; } 将内容写入到pdf中Java codeIOException{ System.out.println(); System.out.println(); ; // create the file File(filePath); file.exists()){ Document doc ; FileOutputStream fos ; PdfWriter pdfWriter ; try { BaseFont bFont ); Font font Font(bFont); font.setSize(8); doc Document(PageSize.A4, margin, margin, margin, margin); fos FileOutputStream(file); pdfWriter = PdfWriter.getInstance(doc, fos); doc.open(); doc.addTitle(filePath.replace()); doc.add(new Paragraph(content, font)); System.out.println(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ ){ doc.close(); } ){ pdfWriter.close(); } ){ fos.close(); } } } } 心愿对你有用哈,我也是以前做测试的时候写的了……