/** * Sets to the {@link PdfStamper} the input map as document metadata adding the creator to it. * * @param meta */ public void setMetadataOnStamper(HashMap<String, String> meta) { meta.put(PdfMetadataKey.CREATOR.getKey(), Sejda.CREATOR); stamper.setMoreInfo(meta); }
public void manipulatePdf(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); Map<String, String> info = reader.getInfo(); info.put("Title", "Hello World stamped"); info.put("Subject", "Hello World with changed metadata"); info.put("Keywords", "iText in Action, PdfStamper"); info.put("Creator", "Silly standalone example"); info.put("Author", "Also Bruno Lowagie"); stamper.setMoreInfo(info); stamper.close(); reader.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param strength <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, boolean strength, String userPassword, String ownerPassword, int permissions, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(strength, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param type the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. * Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, int type, String userPassword, String ownerPassword, int permissions, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(type, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param type the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. * Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @param globalDate * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, int type, String userPassword, String ownerPassword, int permissions, HashMap newInfo, Calendar globalDate) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os, globalDate); stamper.setEncryption(type, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(globalDate); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param strength128Bits <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(userPassword, ownerPassword, permissions, strength128Bits); stamper.setMoreInfo(newInfo); stamper.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param strength <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, boolean strength, String userPassword, String ownerPassword, int permissions, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(strength, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param strength128Bits <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, byte userPassword[], byte ownerPassword[], int permissions, boolean strength128Bits, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(userPassword, ownerPassword, permissions, strength128Bits); stamper.setMoreInfo(newInfo); stamper.close(); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param strength <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @param globalDate * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, boolean strength, String userPassword, String ownerPassword, int permissions, HashMap newInfo, Calendar globalDate) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os, globalDate); stamper.setEncryption(strength, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(globalDate); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param strength128Bits <code>true</code> for 128 bit key length, <code>false</code> for 40 bit key length * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @param globalDate * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, byte userPassword[], byte ownerPassword[], int permissions, boolean strength128Bits, HashMap newInfo, Calendar globalDate) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os, globalDate); stamper.setEncryption(userPassword, ownerPassword, permissions, strength128Bits); stamper.setMoreInfo(newInfo); stamper.close(globalDate); }
/** Entry point to encrypt a PDF document. The encryption parameters are the same as in * <code>PdfWriter</code>. The userPassword and the * ownerPassword can be null or have zero length. In this case the ownerPassword * is replaced by a random string. The open permissions for the document can be * AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, * AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. * The permissions can be combined by ORing them. * @param reader the read PDF * @param os the output destination * @param type the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. * Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext * @param userPassword the user password. Can be null or empty * @param ownerPassword the owner password. Can be null or empty * @param permissions the user permissions * @param newInfo an optional <CODE>String</CODE> map to add or change * the info dictionary. Entries with <CODE>null</CODE> * values delete the key in the original info dictionary * @throws DocumentException on error * @throws IOException on error */ public static void encrypt(PdfReader reader, OutputStream os, int type, String userPassword, String ownerPassword, int permissions, HashMap newInfo) throws DocumentException, IOException { PdfStamper stamper = new PdfStamper(reader, os); stamper.setEncryption(type, userPassword, ownerPassword, permissions); stamper.setMoreInfo(newInfo); stamper.close(); }