How can i do when have error like that: PDF contains an encryption dictionary, please remove it with setAllSecurityToBeRemoved() or set a protection policy with protect()
Please use the unlock pdf tool to remove the PDF encryption and after that, use this newly created unlocked PDF to do what you want. The tools located here: https://tools.pdf24.org/en/unprotect-pdf