Do you have AEM Forms license?
If yes you can use DocAssurance API to reader extend the pdf forms
I have a sample here Aem Forms Samples
Search for "Apply Usage Rights to PDF" which allows you to upload a PDF and it returns the PDF with Usage rights
The following code snippet does what you are looking for
public
Document renderAndExtendXdp(String xdpPath) {
log.debug(
"In renderAndExtend xdp the alias is "
+ docConfig.ReaderExtensionAlias());
PDFFormRenderOptions renderOptions =
new
PDFFormRenderOptions();
renderOptions.setAcrobatVersion(AcrobatVersion.Acrobat_11);
try
{
Document xdpRenderedAsPDF = formsService.renderPDFForm(
"crx://"
+ xdpPath,
null
, renderOptions);
UsageRights usageRights =
new
UsageRights();
usageRights.setEnabledBarcodeDecoding(docConfig.BarcodeDecoding());
usageRights.setEnabledFormFillIn(docConfig.FormFill());
usageRights.setEnabledComments(docConfig.Commenting());
usageRights.setEnabledEmbeddedFiles(docConfig.EmbeddingFiles());
usageRights.setEnabledDigitalSignatures(docConfig.DigitialSignatures());
usageRights.setEnabledFormDataImportExport(docConfig.FormDataExportImport());
ReaderExtensionsOptionSpec reOptionsSpec =
new
ReaderExtensionsOptionSpec(usageRights,
"Sample ARES"
);
UnlockOptions unlockOptions =
null
;
ReaderExtensionOptions reOptions = ReaderExtensionOptions.getInstance();
reOptions.setCredentialAlias(docConfig.ReaderExtensionAlias());
log.debug(
"set the credential"
);
reOptions.setResourceResolver(getResolver.getFormsServiceResolver());
reOptions.setReOptions(reOptionsSpec);
log.debug(
"set the resourceResolver and re spec"
);
xdpRenderedAsPDF = docAssuranceService.secureDocument(xdpRenderedAsPDF,
null
,
null
, reOptions,
unlockOptions);