用java加密pdf时用户密码错误

时间:2017-10-01 17:07:44

标签: java itext pdfstamper

我正在尝试使用以下代码加密pdf文件

public static void securefile(String src, String dest, String passwd, String secure) throws IOException,
                                                                                            DocumentException {
    byte[] USER = "ADEEL".getBytes();
    byte[] OWNER = passwd.getBytes();

    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
    if (secure == "Y") {
        stamper.setEncryption("ADEEL".getBytes(), passwd.getBytes(), PdfWriter.ALLOW_PRINTING,
                              PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
    }
    stamper.setFullCompression();
    stamper.close();
    reader.close();

在调用此方法时,我得到异常bad user password

任何人都可以建议这里发生的错误

0 个答案:

没有答案