Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Reader extension enablement using AEM

Avatar

Avatar
Validate 1
Level 1
amolchavan21
Level 1

Likes

2 likes

Total Posts

1 post

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
amolchavan21
Level 1

Likes

2 likes

Total Posts

1 post

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
amolchavan21
Level 1

26-09-2018

Can AEM designer be used to enable reader extension on a PDF?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile
Mayank_Gandhi
Level 10

26-09-2018

No, you will need an AEM forms Server or Acrobat to reader extend a pdf.

If you have AEM forms JEE server you can use workbench or ReaderExtension UI while with Acrobat you have to just save the form again using File -> Save as Other -> Reader extended PDF

1580019_pastedImage_0.png

Answers (5)

Answers (5)

Avatar

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile
workflowuser
Employee

15-08-2019

I will put out a sample on this soon

Avatar

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 1
Level 10
Mayank_Gandhi
Level 10

Likes

284 likes

Total Posts

1,105 posts

Correct Reply

182 solutions
Top badges earned
Validate 1
Contributor 2
Ignite 5
Ignite 3
Ignite 10
View profile
Mayank_Gandhi
Level 10

15-08-2019

Yes, Aem forms OSGi provides reader extension capabilities as well.

sashish

Hi Mayank_Gandhi,

 

While using reader extension service in Adaptive form, i have set up keystore already and wrote java code to apply usage write but getting exception like below:

com.adobe.fd.docassurance.client.api.impl.DocAssuranceServiceImpl Exception while applying usage rights in DocAssuranceService
com.adobe.fd.readerextensions.client.ProcessingException: AEM-REX-001-008: Unable to apply the requested usage rights to the given document.
at com.adobe.fd.readerextensions.service.impl.ReaderExtensionsServiceImpl.applyUsageRights(ReaderExtensionsServiceImpl.java:215) [com.adobe.aemfd.adobe-aemfd-readerextensions:6.0.26]
at com.adobe.fd.docassurance.client.api.impl.DocAssuranceServiceImpl.addReaderExtensions(DocAssuranceServiceImpl.java:887) [adobe-aemfd-docassurance:6.0.50]
at com.adobe.fd.docassurance.client.api.impl.DocAssuranceServiceImpl.secureDocument(DocAssuranceServiceImpl.java:242) [adobe-aemfd-docassurance:6.0.50]

 

If you have any idea please help

 

Thanks and regards,

Ashish Saxena

Avatar

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 5
Employee
workflowuser
Employee

Likes

133 likes

Total Posts

443 posts

Correct Reply

70 solutions
Top badges earned
Ignite 5
Ignite 3
Ignite 1
Give Back 50
Give Back 5
View profile
workflowuser
Employee

15-08-2019

is this what you wanted?

ApplyReaderExtensions

I will create an article on this soon

the following is the code needed to get this working

import org.osgi.service.component.annotations.Component;

import org.osgi.service.component.annotations.Reference;

import com.adobe.aemfd.docmanager.Document;

import com.adobe.fd.docassurance.client.api.DocAssuranceService;

import com.adobe.fd.docassurance.client.api.ReaderExtensionOptions;

import com.adobe.fd.readerextensions.client.ReaderExtensionsOptionSpec;

import com.adobe.fd.readerextensions.client.UsageRights;

import com.adobe.fd.signatures.pdf.inputs.UnlockOptions;

import com.aemforms.ares.core.ReaderExtendPDF;

import com.mergeandfuse.getserviceuserresolver.GetResolver;

@Component(service=ApplyUsageRights.class,immediate = true)

public class ApplyUsageRights implements ReaderExtendPDF {

@Reference

DocAssuranceService docAssuranceService;

@Reference

GetResolver getResolver;

@Override

public Document applyUsageRights(Document pdfDocument,UsageRights usageRights) {

   ReaderExtensionsOptionSpec reOptionsSpec = new ReaderExtensionsOptionSpec(usageRights, "Sample ARES");

   UnlockOptions unlockOptions = null;

   ReaderExtensionOptions reOptions = ReaderExtensionOptions.getInstance();

   reOptions.setCredentialAlias("ares");

 

   reOptions.setResourceResolver(getResolver.getFormsServiceResolver());

 

   reOptions.setReOptions(reOptionsSpec);

   System.out.println("Applying Usage");

try {

return docAssuranceService.secureDocument(pdfDocument, null, null, reOptions,

     unlockOptions);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return null;

}

}

public class GetReaderExtendedPDF extends SlingAllMethodsServlet {

@Reference

GetResolver getResolver;

@Reference

ApplyUsageRights applyRights;

public org.w3c.dom.Document w3cDocumentFromStrng(String xmlString) {

try {

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();

InputSource is = new InputSource();

is.setCharacterStream(new StringReader(xmlString));

return db.parse(is);

} catch (ParserConfigurationException e) {

e.printStackTrace();

} catch (SAXException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

return null;

}

@Override

protected void doGet(SlingHttpServletRequest request,SlingHttpServletResponse response)

{

doPost(request,response);

}

@Override

protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) {

UsageRights usageRights = new UsageRights();

Enumeration en = request.getParameterNames();

String submittedData = request.getParameter("jcr:data");

System.out.println("The submitted data is "+submittedData);

org.w3c.dom.Document submittedXml = w3cDocumentFromStrng(submittedData);

String formFill = submittedXml.getElementsByTagName("formfill").item(0).getTextContent();

usageRights.setEnabledFormFillIn(Boolean.valueOf(submittedXml.getElementsByTagName("formfill").item(0).getTextContent()));

usageRights.setEnabledComments(Boolean.valueOf(submittedXml.getElementsByTagName("comments").item(0).getTextContent()));

usageRights.setEnabledEmbeddedFiles(Boolean.valueOf(submittedXml.getElementsByTagName("attachments").item(0).getTextContent()));

usageRights.setEnabledDigitalSignatures(Boolean.valueOf(submittedXml.getElementsByTagName("digitalsignatures").item(0).getTextContent()));

String attachmentPath = submittedXml.getElementsByTagName("attachmentpath").item(0).getTextContent();

System.out.println("The attachmentPath "+attachmentPath);

Node pdfNode = getResolver.getFormsServiceResolver().getResource(attachmentPath).adaptTo(Node.class);

javax.jcr.Node jcrContent = null;

try {

jcrContent = pdfNode.getNode("jcr:content");

System.out.println("The jcr content node path is " + jcrContent.getPath());

} catch (RepositoryException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

try {

InputStream is = jcrContent.getProperty("jcr:data").getBinary().getStream();

Session jcrSession = getResolver.getFormsServiceResolver().adaptTo(Session.class);

Document documentToReaderExtend = new Document(is);

documentToReaderExtend = applyRights.applyUsageRights(documentToReaderExtend,usageRights);

documentToReaderExtend.copyToFile(new File("c:\\scrap\\doctore.pdf"));

InputStream fileInputStream = documentToReaderExtend.getInputStream();

response.setContentType("application/pdf");

response.addHeader("Content-Disposition", "attachment; filename=AemFormsRocks.pdf");

response.setContentLength((int) fileInputStream.available());

OutputStream responseOutputStream = response.getOutputStream();

int bytes;

while ((bytes = fileInputStream.read()) != -1) {

responseOutputStream.write(bytes);

}

responseOutputStream.flush();

responseOutputStream.close();

documentToReaderExtend.close();

} catch (ValueFormatException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (PathNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (RepositoryException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

while(en.hasMoreElements())

{

System.out.println("The parameter name is "+en.nextElement());

}

}

}

Avatar

Avatar
Give Back
Level 2
brandonl8713581
Level 2

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 3
Ignite 1
Validate 1
Boost 1
View profile

Avatar
Give Back
Level 2
brandonl8713581
Level 2

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 3
Ignite 1
Validate 1
Boost 1
View profile
brandonl8713581
Level 2

15-08-2019

Thanks! Much appreciated

Avatar

Avatar
Give Back
Level 2
brandonl8713581
Level 2

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 3
Ignite 1
Validate 1
Boost 1
View profile

Avatar
Give Back
Level 2
brandonl8713581
Level 2

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Give Back
Ignite 3
Ignite 1
Validate 1
Boost 1
View profile
brandonl8713581
Level 2

15-08-2019

Can this be done on a OSGI server as well?