List of usage examples for com.lowagie.text.pdf PdfWriter DO_NOT_ENCRYPT_METADATA
int DO_NOT_ENCRYPT_METADATA
To view the source code for com.lowagie.text.pdf PdfWriter DO_NOT_ENCRYPT_METADATA.
Click Source Link
From source file:questions.encryption.HelloWorldMetadataNotEncrypted.java
public static void main(String[] args) { // step 1//w w w .ja v a 2 s .c o m Document document = new Document(); try { // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); writer.setEncryption("hello".getBytes(), "world".getBytes(), 0, PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA); writer.createXmpMetadata(); writer.setPdfVersion(PdfWriter.VERSION_1_5); // step 3 document.open(); // step 4 document.add(new Paragraph("Hello World")); writer.addAnnotation(PdfAnnotation.createFileAttachment(writer, new Rectangle(100f, 650f, 150f, 700f), "This is some text", "some text".getBytes(), null, "some.txt")); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5 document.close(); }