Hi Team,
I am trying to add password and digital Sign PDF files using ASPOSE PDF API. For small PDF files the programs runs with out any issues but for large PDF Files (more than 1 MB) every time OUT OF MEMORY EXCEPTION will be thrown. I am pasting the code below.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class PasswordTest {
public static void main(String[] args) throws Throwable {
com.aspose.pdf.Document document = new com.aspose.pdf.Document("C:\\demo\\test.pdf");
//encrypt PDF
document.encrypt("user", "india", 0, com.aspose.pdf.CryptoAlgorithm.AESx256);
//save updated PDF
document.save("C:\\demo\testing-pwd.pdf");
System.out.println("end");
}
}
package com.pdf;
import com.aspose.pdf.PKCS1;
public class AsposeDigitalSignForPdfFile {
public static void main(String[] args) {
com.aspose.pdf.facades.PdfFileSignature pdfSign = new com.aspose.pdf.facades.PdfFileSignature();
pdfSign.bindPdf("d:/demo/TestFile.pdf");
java.awt.Rectangle rect = new java.awt.Rectangle(100, 100, 200, 100);
//set signature appearance
pdfSign.setSignatureAppearance("D:/demo/Sign.png");
PKCS1 signature = new PKCS1("d:/demo/digitialfile.pfx", "india");
pdfSign.sign(1, "test", "test", "Bangalore", true, rect, signature);
System.out.println("sign done");
pdfSign.save("d:/demo/TestFileSigned.pdf");
}
}
I am using aspose-pdf-10.3.0.jar here. your help in this is regard is highly appreciated.
Regards
Balu