The method is like this, call directly.
The public static void symbol (string before Pdfpath, string after Pdfpath, pngpath string) throws an exception {
//KeyStore ks = KeyStore . getinstance(" pkcs 12 ");
//ks . load(new file inputstream(" demo . p 12 ")," 123456 "。 toCharArray()); // 123456 is the private key password.
//String alias =(String)ks . aliases()。 next element();
//privatekeykey = (privatekey) ks.getkey (alias, "123456"). toCharArray());
//certificate [] chain = ks.get certificate chain (alias);
Log.d("pdfd "," do- 1 ");
pdf reader reader = new pdf reader(before pdf path); //source file
Log.d("pdfd "," do- 1-0 1 ");
file output stream fout = new file output stream(afterpdf path);
Log.d("pdfd "," do- 1- 1 ");
PdfStamper STP = PdfStamper . create signature(reader,fout,' \ 0 ');
PdfSignatureAppearance sap = STP . getsignaturerenance();
//sap . set crypto(key,chain,null,PdfSignatureAppearance。 VERISIGN _ SIGNED);
Log.d("pdfd "," do-2 ");
sap . set reason(" ");
sap . set location(" ");
sap . set contact("/");
image image = image . getinstance(png path); //Use transparent pictures in png format.
Log.d("pdfd "," do-3 ");
sap . setsignaturegraphic(image);
sap . seta cro 6 layers(true);
sap . setrenderingmode(rendering mode。 Graphic);
Sap.setVisibleSignature (new rectangle (300,600,400,675), 1, null); //300 and 600 are the coordinates corresponding to the X axis and the Y axis.
stp.getWriter()。 setCompressionLevel(5);
Log.d("pdfd "," do-4 ");
If (stp! = null) {
Log.d("pdfd "," do-4- 1 ");
STP . close();
Log.d("pdfd "," do-4-2 ");
}
Log.d("pdfd "," do-5 ");
If (fout! = null) {
fout . close();
}
Log.d("pdfd "," do-6 ");
If (reader! = null) {
reader . close();
}
Log.d("pdfd "," do-7 ");
}