瘋狂

          STANDING ON THE SHOULDERS OF GIANTS
          posts - 481, comments - 486, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          使用apache pdfbox讀取pdf 實例

          Posted on 2011-02-24 14:55 瘋狂 閱讀(2787) 評論(2)  編輯  收藏 所屬分類: java apache項目
          public static void main(String[] args) throws Exception {
              InputStream inputStream 
          = new BufferedInputStream(
                      
          new FileInputStream(new File("d:\\work\\lt.pdf")));
              PDDocument pdfDocument 
          = PDDocument.load(inputStream);
              StringWriter writer 
          = new StringWriter();
              PDFTextStripper stripper 
          = new PDFTextStripper();
              stripper.writeText(pdfDocument, writer);
              String contents 
          = writer.getBuffer().toString();
              System.out.println(
          "文檔內(nèi)容:"+contents);
              PDDocumentInformation documentInformation 
          = pdfDocument.getDocumentInformation();
              System.out.println(
          "標(biāo)題:"+documentInformation.getTitle());
          }

          }
          需要jar包:
          pdfbox-1.4.0.jar
          fontbox-1.4.0.jar

          評論

          # re: 使用apache pdfbox讀取pdf 實例[未登錄]  回復(fù)  更多評論   

          2011-04-21 05:16 by water
          利用本程序解決了我的問題。謝謝!
          主站蜘蛛池模板: 广水市| 穆棱市| 甘泉县| 崇左市| 越西县| 德化县| 邯郸市| 宜黄县| 昌宁县| 喀什市| 平潭县| 太和县| 崇阳县| 荆门市| 昌乐县| 运城市| 新竹县| 彰化市| 靖远县| 大厂| 台安县| 沧州市| 交口县| 留坝县| 堆龙德庆县| 湖州市| 乐都县| 德昌县| 赣榆县| 金堂县| 遂川县| 汾阳市| 资阳市| 故城县| 文登市| 福泉市| 顺义区| 颍上县| 济宁市| 高唐县| 昆明市|