Skip to main content
Participant
March 13, 2021
Question

How to create a PDF viewer template

  • March 13, 2021
  • 2 replies
  • 1461 views

I have many PDF documents for my website.

 

Instead of creating a seprate html page for each of them, I wish to use one html page, and as a visitor clicks on any link, that specific pdf document name will be passed into the script to invoke a view

 

How can I do that? Below is my page sample

Thanks

 

<!DOCTYPE html>
<html>
<head>
<title>Adobe Document Services PDF Embed API Sample</title>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body style="margin: 0px">
<div id="adobe-dc-view"></div>

<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: "MY KEY", divId: "adobe-dc-view"});
adobeDCView.previewFile(
{
// content: {location: {url: "https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf"}},
content: {location: {url: "https://squadron-125.org.il/mypdf/bugi.pdf"}},
// metaData: {fileName: "Bodea Brochure.pdf"}
metaData: {fileName: "bugi.pdf"}
});
});
</script>

</body>
</html>

    This topic has been closed for replies.

    2 replies

    Participant
    March 21, 2021

    Yes, all OK now and I have a template that works the way I wanted it

     

    I have one problem left. Some of the PDF documents are large and take a long time to lad into view

    Is there a way to make it load asynchronuosly - load the first page into vie and continue loading the rest of the pages in the background?

     

    If so, how?

     

    Thanks again

    Alex

    Legend
    March 21, 2021

    That is "page at a time loading", which Adobe invented over 20 years ago to solve this problem. Unfortunately, the new online services have chosen to ignore this wonderful invention, presumably because all the developers involved have incredibly fast internet, unlike much of the rest of the world... ! The best you can do is place a "document loading" sort of message in your page first. 

    Joel Geraci
    Community Expert
    Community Expert
    March 13, 2021

    I have a working example of what you are looking to do at this CodePen.