Our Java based sample code merely converts files to PDF. If you wish to secure the generated PDF in the process then add the following code to the getConversionSettings() method and amend as needed.
Access the full source code on GitHub.
// ** This is the only change needed to apply PDF security. In this example we'll
// ** leave the 'open password' empty. An 'owner password' is specified, which
// ** will cause the PDF to be encrypted and security options to be applied.
// ** Due to the way 'wsimport' based web service clients work, members of the
// ** SecurityOptions enum need to be passed as strings
ObjectFactory of = new ObjectFactory();
conversionSettings.setOpenPassword(of.createConversionSettingsOpenPassword(""));
conversionSettings.setOwnerPassword(
of.createConversionSettingsOwnerPassword("SomeOwnerPassword"));
conversionSettings.getSecurityOptions().add("DisablePrint");
conversionSettings.getSecurityOptions().add("DisableHighResolutionPrint");
conversionSettings.getSecurityOptions().add("DisableContentCopy");
conversionSettings.getSecurityOptions().add("DisableAnotations");
conversionSettings.getSecurityOptions().add("DisableFormFields");
conversionSettings.getSecurityOptions().add("DisableContentAccessibility");
conversionSettings.getSecurityOptions().add("DisableDocumentAssembly");
This sample code assumes that the standard 'wsimport' method has been used to generate Web Service proxies. The Axis2 syntax is similar although slightly less complicated.
0 Comments