2013-02-08 39 views

Trả lời

7

Hãy thử mã này:

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

tuyệt vời ... làm việc của mình ... Cảm ơn u r phản ứng nhanh chóng @ SAN3 – Ganeshja

+0

Tại sao các tài liệu khai thác văn bản được mã hóa là chậm hơn nhiều so với một bình thường không? 5 ~ 10 lần chậm hơn. Có anyway để tăng tốc độ? – 1a1a11a

1

Bạn chỉ có thể sử dụng

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(); 
    } 
} 
Các vấn đề liên quan