Displaying Multiple PDFs on the Same Page

Community Beginner ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

I have a page containing five policies, each one a PDF, and I want to display them in an accordion where expanding each one brings up the corresponding embedded PDF using PDF Embed API.  I've tried changing the name of the variable and the ID of the div, but only the first PDF shows, and the rest are blank.

 

How is this accomplished?

Views

157

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Did you figure this out?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

No, I had to use a different PDF embedder.  Shame because Adobe's is so nice.  Wish someone would help a girl out lol.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

Hi, Thanks for trying out PDF Embed API. Ideally, it should work by creating a new object of AdobeDC.View for each of the PDFs. It would be great for us to debug if you can share your snippet or website.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

I'm using the standard recommended code:

<div id="adobe-dc-view" style="width: 100%;"></div>
<p><script src="https://documentcloud.adobe.com/view-sdk/main.js"></script> <script type="text/javascript">
  document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
    var adobeDCView = new AdobeDC.View({clientId: "--client id removed-", divId: "adobe-dc-view"});
    adobeDCView.previewFile({
      content:{location: {url: "<span id="tb-shortcode-6" data-tb-shortcode-id="6" class="tb-fields-and-text-shortcode-render tb-fields-and-text-shortcode-render-types"><!-- TBINNERSTART 6 -->Loading…<!-- TBINNEREND 6 --></span>"}},
      metaData:{fileName: "Committee File"}
    }, {embedMode: "IN_LINE"});
  });
  </script>

I just need to know how to manipulate the code to make multiple iterations work on one page.  How do I create a new object?

 

Thanks for your help. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2021 Mar 25, 2021

Copy link to clipboard

Copied

The code I actually used didn't have the shortcode as the URL.  It just had the direct path to each file. As in:

<div id="adobe-dc-view" style="width: 100%;"></div>
<p><script src="https://documentcloud.adobe.com/view-sdk/main.js"></script> <script type="text/javascript">
  document.addEventListener("adobe_dc_view_sdk.ready", function(){ 
    var adobeDCView = new AdobeDC.View({clientId: "-client-id-removed-", divId: "adobe-dc-view"});
    adobeDCView.previewFile({
      content:{location: {url: "-url-to-file-"}},
      metaData:{fileName: "Committee File"}
    }, {embedMode: "IN_LINE"});
  });
  </script>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

I got it to work with multiple instances in a ginle page.

 

Change the id to be unique:

adobe-dc-view

Becomes

adobe-dc-view-1

 Then update the var in each instance to match the new unique id 

var adobeDCView = new AdobeDC.View({clientId: "-client-id-removed-", divId: "adobe-dc-view-1"});

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

Thank you I will give this a try and post what happens.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

LATEST

Just to confirm, this DOES work.  My accordion plugin is acting a bit finicky with it, but that's another matter.  Thanks for the help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines