Created
October 12, 2020 08:52
-
-
Save OmidNejadabbasi/68fd1d30ed67d252a89250e87cf8929f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import org.apache.pdfbox.pdmodel.PDDocument; | |
import org.apache.pdfbox.pdmodel.encryption.AccessPermission; | |
import org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy; | |
public class Main { | |
public static void main(String[] args) throws IOException { | |
PDDocument pdDocument =PDDocument.load(new File("new.pdf")); | |
AccessPermission access=new AccessPermission(); | |
access.setCanPrint(false); | |
StandardProtectionPolicy policy=new StandardProtectionPolicy("123", "456", access); | |
pdDocument.protect(policy); | |
pdDocument.save("new.pdf"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment