import com.aspose.pdf.*; import com.aspose.pdf.facades.DocumentPrivilege; import com.aspose.pdf.facades.KeySize; import com.aspose.pdf.facades.PdfFileInfo; import com.aspose.pdf.facades.PdfFileSecurity; public class Main { public static void main(String[] args) throws Exception {//Change the owner and user Password in a PDF // Load a license License lic = new License(); lic.setLicense("Aspose.Total.lic"); // Instantiate an object of the PdfFileInfo class object PdfFileInfo pdfFileInfo = new PdfFileInfo("PasswordPDF.pdf"); // Check if the existing file is encrypted due to a password protection if (pdfFileInfo.isEncrypted()) { // Create a PdfFileSecurity object PdfFileSecurity fileSecurity = new PdfFileSecurity(); // Bind the target PDF file fileSecurity.bindPdf("PasswordPDF.pdf"); // Set the new owner and user password fileSecurity.changePassword("owner", "new_owner", "new_user", DocumentPrivilege.getCopy(), KeySize.x256); //Save the resultant PDF file fileSecurity.save("UpdatedPassword.pdf"); } System.out.println("Done"); } }