Hi Team,
I am using aspose-pdf-10.3.0.jar(Trial version) to add password for PDF files. But I am getting OUT OF MEMORY Exception when I run the program. Very few times the program runs successfully and password will be added to the pdf file. Is this due to limited version which I am using? Your help in this regard is highly appreciated. I am pasting the code below for your reference. For small PDF files this works fine but if the pdf file size is more than 2 MB this will give out of memory exception
package com.pdf;
public class AddPassword {
public static void main(String[] args) {
com.aspose.pdf.Document document = new com.aspose.pdf.Document(“C:\Sample.pdf”);
//encrypt PDF
document.encrypt(“user”, “india123”, 0, com.aspose.pdf.CryptoAlgorithm.AESx256);
//save updated PDF
document.save(“C:\Sample-pwd.pdf”);
System.out.println(“password added”);
}
}
Regards
Balu