我有一个带有粘滞便笺的文件。如何使用PDFBox读取便笺的内容?

最佳答案

找到了。这是我的代码

PDDocument pdfFile;
PDFTextStripper stripper;
List allPages;
PDPage page;
List<PDAnnotation> la = new ArrayList<PDAnnotation>();

stripper = new PDFTextStripper();
File file = new File("C:\\Users\\idobles\\Desktop\\CFM\\6 402402424.pdf");
pdfFile = PDDocument.load(file);
allPages = pdfFile.getDocumentCatalog().getAllPages();
for(int i = 0; i < allPages.size(); i++){
     page = (PDPage) allPages.get(i);
     la = page.getAnnotations();
    if(la.size() < 1){
        continue;
    }
}


la对象应具有存储在地图中的项目列表。使用“内容”键可以在便笺内获取信息。希望这对某人有帮助!

10-04 18:45