Issues with PDF Viewer | Community
Skip to main content
Level 6
April 21, 2021
Solved

Issues with PDF Viewer

  • April 21, 2021
  • 2 replies
  • 10832 views

Hello All - We have extended the PDF viewer core component into our app : /apps/app-name/ by following the below medium article and also created the "Content Aware configuration" under /conf/app-name/ and added the property "sling:configRef" that points to Context Aware Config path under /content/site/.

 

https://medium.com/adobetech/pdfs-in-aem-embed-pdfs-into-your-pages-with-pdf-viewer-7115c60b3c34

 

After we made all the requirement changes and specify the PDF path in the dialog, the component is not rendering the PDF. The component is not editable and we are able to open the dialog only from Side Panel -> Content Tree. Please see the attached screenshot. Can someone tell me what could be the issue?

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijayalakshmi_S

Hi @test1234567,

One of the possible cause would be the clientId used in sling:configs. Can you confirm if it is the valid one generated for your application. 

If yes, you can cross check directly by placing the markup(code snippet available in below link) in any component or in base page component. (by hardcoding the clientId and specific document instead of via PDF viewer component. Based on this result, we can narrow down the issue)

More details related to this in this documentation - https://medium.com/adobetech/easily-embed-pdf-into-your-website-using-adobe-document-cloud-view-sdk-3a40094f27b6

 

2 replies

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
April 21, 2021

Hi @test1234567,

One of the possible cause would be the clientId used in sling:configs. Can you confirm if it is the valid one generated for your application. 

If yes, you can cross check directly by placing the markup(code snippet available in below link) in any component or in base page component. (by hardcoding the clientId and specific document instead of via PDF viewer component. Based on this result, we can narrow down the issue)

More details related to this in this documentation - https://medium.com/adobetech/easily-embed-pdf-into-your-website-using-adobe-document-cloud-view-sdk-3a40094f27b6

 

Level 6
April 27, 2021

@vijayalakshmi_s- Thank you so much for your suggestion. I was trying to override getClientId() method by using sling model delegation pattern. I am getting any error with the bundle activation. Can you advise what could be the issue?

<core.wcm.components.version>2.10.0</core.wcm.components.version>

---------------------

import com.adobe.cq.wcm.core.components.internal.services.pdfviewer.PdfViewerCaConfig;
import com.adobe.cq.wcm.core.components.models.PdfViewer;
import lombok.experimental.Delegate;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.caconfig.ConfigurationBuilder;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.via.ResourceSuperType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

@Model(
adaptables = {Resource.class, SlingHttpServletRequest.class},
adapters = PdfViewer.class,
resourceType = "test/components/content/pdfviewer",
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)

public class CustomPdfViewer implements PdfViewer {

private static final Logger LOG = LoggerFactory.getLogger(CustomPdfViewer.class);

@Self
@Via(type = ResourceSuperType.class)
@Delegate(excludes = DelegationExclusion.class)
private PdfViewer delegate;

@Inject
private Resource resource;

private PdfViewerCaConfig caConfig;

@PostConstruct
protected void initModel() {
ConfigurationBuilder cb = (ConfigurationBuilder)this.resource.adaptTo(ConfigurationBuilder.class);
if (cb != null)
this.caConfig = (PdfViewerCaConfig)cb.as(PdfViewerCaConfig.class);
}

@Override
public String getClientId() {
LOG.info("~~~~~~~~~~~~~ CustomPdfViewer ~~~~~~~~~~~~~");
return this.caConfig.clientId();
}
private interface DelegationExclusion {
String getClientId();
}
}

 

 

 

 

fabiotust1
Level 2
February 6, 2023

Hi @vijayalakshmi_s I followed the replies and I appreciate all your help with the PDV Viewer component. But I didn't understand how I can configure my environments to work. 

Could you please help me?

 

I have my PDF Viewer as a proxy component on my local. I used the Override CA Config to have my clientId number working on my localhost. But how I can have the configs to the other clientIds related to my other domains? For example, I need a different clientId for my dev author environment, because it has a different domain. 

I tried the CA Configuration Override solution. It works on my local, but how I can specify the dev author? I tried to add more lines on the Override with .dev.author, but seems that these lines are no readable by my author-dev instance.