Here is the piece of code that I am using:
InitialContext namingContext = new InitialContext();
Object dmObject = namingContext.lookup("DataManagerService");
ConnectionFactory dmConnectionFactory = (ConnectionFactory) PortableRemoteObject.narrow(dmObject,ConnectionFactory.class);
UserTransaction transaction = (UserTransaction) namingContext.lookup("java:comp/UserTransaction");
transaction.begin();
DataManager mDataManager = DataManagerHelper.narrow((org.omg.CORBA.Object)dmConnectionFactory.
getConnection());
DataBuffer pdfFile = DMUtils.getDataBuffer(mDataManager, bis);
InitialContext pdfnamingContext = new InitialContext();
Object pdfObject = namingContext.lookup("PDFManipulation");
ConnectionFactory pdfConnectionFactory = (ConnectionFactory) PortableRemoteObject.narrow(pdfObject,ConnectionFactory.class);
PDFFactory mPDFFactory = PDFFactoryHelper.narrow((org.omg.CORBA.Object)pdfConnectionFactory.
getConnection());
PDFDocument pdf = mPDFFactory.openPDF(pdfFile);
Rectangle rect = new Rectangle(400, 750, 100, 25);
SignatureField sigField = pdf.addSignatureField("MyField", 1, rect);
String actualFieldName = sigField.getFieldName();
System.out.println("Signature Field:" +actualFieldName);
String licenseId = pdf.applyPolicy(PolicyId, "adamani", "password", "PicnicPdfDoc", "000003");
DataBuffer pdfDataBuffer = pdf.save();
long pdfSize = pdfDataBuffer.getBufLength();
byte [] pdfData = pdfDataBuffer.getBytes(0,pdfSize);
File myFile = new File("C:\\Test2.pdf");
OutputStream myFileW = new FileOutputStream(myFile);
myFileW.write(pdfData);
myFileW.close();
output_stream.write(pdfData);
transaction.commit();