我无法使用itexpdf解密

问题描述 投票:0回答:1

我无法解密pdf,它只是将其复制到新目录中。请指教。谢谢

    public static void pdfReader () throws FileNotFoundException, DocumentException, IOException
{
    String password="Sec#1234";

    File SRC = new File("C:\\Attachments\\secure.pdf");
  //File SRC = new File(System.getProperty("java.io.tmpdir"));
    String inPath=SRC.getAbsolutePath();

    File DEST =  new File("C:\\Outbox\\secure.pdf");
    String outPath=DEST.getAbsolutePath();

    PdfReader reader = new PdfReader(inPath,password.getBytes())
    PdfReader.unethicalreading = true;

    System.out.println("Is the PDF Encrypted ? :: "+ reader.isEncrypted());

    //reader.decryptOnPurpose(true);
    //System.out.println(new String(reader.computeUserPassword()));
    //PdfDocument pdf = new PdfDocument(reader, new PdfWriter(outPath));

    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outPath));

    stamper.close();
    reader.close();
encryption itext pdf-reader
1个回答
0
投票

我刚刚将阅读器内容初始化为String变量String s = new String(reader.getPageContent(1));然后,我使用字符串contains方法验证了页面内容。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.