2013-02-08 7 views

Antwort

7

diesen Code Versuchen:

private void openPDFDoc(final File pdfFile) throws Exception { 
     File originalPDF = pdfFile; 
     PDFParser parser = new PDFParser(new BufferedInputStream(new FileInputStream(
       originalPDF))); 
     parser.parse(); 

     PDDocument originialPdfDoc = parser.getPDDocument(); 

     boolean isOriginalDocEncrypted = originialPdfDoc.isEncrypted(); 
     if (isOriginalDocEncrypted) { 
      originialPdfDoc.openProtection(new StandardDecryptionMaterial("password")); 
     } 
    } 
+0

awesome ... seine Arbeits ... Danke für u schnelle Antwort r @ SAN3 – Ganeshja

+0

Warum das verschlüsselte Dokument Textextraktion ist viel langsamer als normal ein? 5 ~ 10 mal langsamer. Gibt es trotzdem etwas zu beschleunigen? – 1a1a11a

1

Sie können mit nur

public static void main(String[] args){ 
PDDocument pd; 
try { 
    File input = new File("p.pdf"); // password protected PDF file from where you would like to extract 
    pd = PDDocument.load(input,"your_password"); 
    pd.setAllSecurityToBeRemoved(true); 

    //for printing pdf file data 
    PDFTextStripper reader = new PDFTextStripper(); 
    String pageText = reader.getText(pd); 
    System.out.println(pageText); 
    } catch (Exception e){ 
    e.printStackTrace(); 
    } 
}