The following Java code example removes a digital signature
from a signature field named SignatureField1. The name of
the PDF file that contains the signature field is LoanSigned.pdf.
(See Removing Digital Signatures.)
/**
* Ensure that you create Java proxy files that consume
* the Signature services WSDL. You can use JAX-WS to create
* the proxy Java files.
*
* For information, see "Invoking LiveCycle using SwaRef" in Programming with LiveCycle
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.ws.BindingProvider;
import com.adobe.idp.services.*;
public class ClearSignatureFieldSWAref {
public static void main(String[] args) {
try
{
// Create a SignatureServiceService object
SignatureServiceService signatureService = new SignatureServiceService();
SignatureService signatureClient = signatureService.getSignatureservice();
//Set LiveCycle connection values
String url = "http://hiro-xp:8080/soap/services/signatureservice?blob=swaRef";
String username = "administrator";
String password = "password";
((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
((BindingProvider) signatureClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
//Set an input file as a BLOB
String path1 = "C:\\Adobe\LoanSigned.pdf";
FileDataSource ds1 = new FileDataSource(path1);
DataHandler handler1 = new DataHandler(ds1);
BLOB inDoc = new BLOB();
inDoc.setSwaRef(handler1);
//Specify the name of the signature field
String fieldName = "SignatureField1";
//Clear the signature field
BLOB outPDF = signatureClient.clearSignatureField(inDoc,fieldName);
//Create a new file containing the returned PDF document
File f = new File("C:\\Adobe\Loan.pdf");
BLOB outBlob = outPDF;
DataHandler handler2 = outBlob.getSwaRef();
//Get an InputStream from DataHandler and
//write to a file
InputStream inputStream = handler2.getInputStream();
OutputStream out = new FileOutputStream(f);
//Iterate through the buffer
byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0)
out.write(buf, 0, len);
out.close();
inputStream.close();
}
catch (Exception ee)
{
ee.printStackTrace();
}
}
}
|
|
|