Now your generated PDF is password protected. tEncryption(USER_PASS.getBytes(), OWNER_PASS.getBytes(), PdfWriter.ALLOW_COPY,ĭocument.add(new Paragraph("Welcome to ")) ĭocument.add(new Paragraph("Don't worry, your pdf document is protected with password.")) PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("iText/protected-doc.pdf")) Private static String OWNER_PASS = "GOD999" ĭocument document = new Document(PageSize.A4, 20, 20, 20, 20) Private static String USER_PASS = "RAM123" To resolve the JAR dependencies, add following in your pom.xml ![]() Throws: DocumentException – if the document is already open JAR Dependencies Can be null or empty.ĮncryptionType – can be any of the following: The open permissions for the document can be AllowPrinting, AllowModif圜ontents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. iText 7 return Pdf de Asp. You can rate examples to help us improve the quality of examples. This constant may only be changed by Paulo Soares and/or Bruno Lowagie. In this case, the ownerPassword is replaced by a random string. Images can be added very easily in the tables using the table.addCell(Image image) method. ![]() The userPassword and the ownerPassword can be null or have zero length. Sets the encryption options for this document. SetEncryption public void setEncryption(byte userPassword, byte ownerPassword, int permissions, int encryptionType) We need to pass the arguments in the method while creating new documents. ![]() tEncryption() method is used to encrypt the PDF document while creating it. SetEncryption( null, (PASSWORD), PdfWriter.ALLOWPRINTING, PdfWriter. In this Java tutorial, we are going to show how you will protect your pdf document with a password using iText API. IText API- Protect PDF Document with Password in Java
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |