2013-07-31 38 views
1

我需要從pdf文件中檢索一些與關鍵字相關的數據。這些是關鍵字:標題,pdf的範圍,誰提出了pdf,版本,摘要,狀態,監管機構。從pdf中檢索特定部分的數據

有什麼工具可以從pdf中檢索數據嗎? 由於提前

回答

0

考慮從PDF Apache PDFBox

提取文本,然後分析它來得到你想要的信息。這是免費的。

另外還有另一個工具,iText但如果您正在從事商業項目,則需要在iText上購買許可證。

2

你可以使用PDFBox from Apache,說實話我從來沒有用過它,但在論壇上看了很多。

其他替代方案可以是iTextJPedal

如果您有興趣可以嘗試一下,但我相信在PDFBox中您將能夠滿足您的要求。

感謝

+0

我想檢索內容相關的數據與內容...像標題包含標題名稱等等...在這裏我想提取標題和標題名稱。我會給只有標題它應該檢索所有pdf的標題名稱 – Subbu

+0

剩下的所有數據都不需要什麼關鍵字,我只通過我想要的數據。 – Subbu

0

使用PDFBOX

public class PDFTextReader 
{ 
    static String pdftoText(String fileName) { 
     PDFParser parser; 
     String parsedText = null; 
     PDFTextStripper pdfStripper = null; 
     PDDocument pdDoc = null; 
     COSDocument cosDoc = null; 
     File file = new File(fileName); 
     if (!file.isFile()) { 
      System.err.println("File " + fileName + " does not exist."); 
      return null; 
     } 
     try { 
      parser = new PDFParser(new FileInputStream(file)); 
     } catch (IOException e) { 
      System.err.println("Unable to open PDF Parser. " + e.getMessage()); 
      return null; 
     } 
     try { 
      parser.parse(); 
      cosDoc = parser.getDocument(); 
      pdfStripper = new PDFTextStripper(); 
      pdDoc = new PDDocument(cosDoc); 
      // pdfStripper.setParagraphStart(FIND_START_VALUE); 
      // pdfStripper.setParagraphEnd("FIND_END_VALUE); 
      parsedText = pdfStripper.getText(pdDoc); 
     } catch (Exception e) { 
      System.err 
        .println("An exception occured in parsing the PDF Document." 
          + e.getMessage()); 
     } finally { 
      try { 
       if (cosDoc != null) 
        cosDoc.close(); 
       if (pdDoc != null) 
        pdDoc.close(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
     return parsedText; 
    } 
    public static void main(String args[]){ 

     System.out.println(pdftoText(FILEPATH)); 
    } 
} 

這裏我想這提取部分。這可能會幫助你。

+0

謝謝Q ...這個程序我已經做..它將轉換總的PDF文件到文本數據我不想這樣實際我的要求是我通過一些關鍵字像標題/總結/日期等應檢索標題的pdf和它有什麼總結和pdf的日期是這樣的..... – Subbu

+0

你可以從PDF中提取特定部分,然後使用你的密鑰來提取值。 – newuser

+0

剩下的所有數據都不需要什麼關鍵字我只通過我想要的數據。 – Subbu