Password-protected PDF merge and rotation is a GroupDocs.Merger capability for Java that enables unlocking, joining, and re-protecting PDF files with custom credentials.
This gist demonstrates how to handle password-protected PDF documents using GroupDocs.Merger for Java (Java). It covers checking protection status, unlocking files, merging unlocked content, and rotating passwords on the final document.
This snippet shows four core operations: isDocumentProtected checks if a PDF is encrypted using isPasswordSet(), unlockAll decrypts multiple files and returns raw bytes, mergeAndProtect joins decrypted streams and applies a new password via AddPasswordOptions, and rotateUnifiedPassword updates the password on an existing protected file using updatePassword().
README.md- this overview.PasswordMergeDemo.java- the entire example, ~30 lines, heavy comments.
- Maven:
mvn dependency:get -Dartifact=com.groupdocs:groupdocs-merger:24.6
- The API supports PDF, DOCX, XLSX, PPTX, and other formats; this example focuses on PDF.
- Input files may be password-protected or plain; the snippet handles both cases via
LoadOptions. - This minimal form is ideal for batch processing pipelines; full projects may include logging, error handling, and UI.
GroupDocs.Merger for Java provides document manipulation features including merge, split, rotate, and password management for PDF, Office, and other formats in Java environments. This snippet exercises Merger, isPasswordSet(), removePassword(), join(), addPassword(), and updatePassword().