Skip to main content
Participating Frequently
May 29, 2020
Question

A way to preview a local PDF?

  • May 29, 2020
  • 1 reply
  • 830 views

I'm running into an issue where I cannot preview a local pdf.

I have tried:

 

 <script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function()
    {
        var adobeDCView = new AdobeDC.View({clientId: "43b7fe695ddb49899bd5d90f222f5b7c", divId: "adobe-dc-view"});
        adobeDCView.previewFile(
       {
          content:   {location: {url: "local_file.pdf"}},
          metaData: {fileName: "local_file.pdf"}
       }, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
    });
 </script>

 

and:

 

 <script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function()
    {
        var adobeDCView = new AdobeDC.View({clientId: "43b7fe695ddb49899bd5d90f222f5b7c", divId: "adobe-dc-view"});
        adobeDCView.previewFile(
       {
          content:   {location: {url: "/local_file.pdf"}},
          metaData: {fileName: "local_file.pdf"}
       }, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
    });
 </script>

 

and:

 

 <script type="text/javascript">
    document.addEventListener("adobe_dc_view_sdk.ready", function()
    {
        var adobeDCView = new AdobeDC.View({clientId: "43b7fe695ddb49899bd5d90f222f5b7c", divId: "adobe-dc-view"});
        adobeDCView.previewFile(
       {
          content:   {location: {url: "file:///C:/my/sandbox/local_file.pdf"}},
          metaData: {fileName: "local_file.pdf"}
       }, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
    });
 </script>

 

but all three don't work.

 

I always just get a "File preview error":

 

In the Adobe View SDK repo, I did see the "Work with Local File" example.  But this is not what I'm looking for.  In the example, it uses a File Uploader.  For my purposes, I want to just hardcode a local file location for my PDF into my JS code (preferably relative to my index.html file).  That way I can easily work on my local machine.

 

Can you please advise?  Thank you!

 

PS.  Note that my index.html is located in "file:///C:/my/sandbox/" in the same dir as local_file.pdf.

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    June 17, 2021

    Did you ever work this out?

    Raymond Camden
    Community Manager
    Community Manager
    June 17, 2021

    In general web browsers tend to lock that kind of stuff down quite strongly. Imagine if I could read your PDFs and send them to a remote domain? If you want to test _completely_ locally you can of course, but you should fire up a local web server and load it via a relative path. If you need help on running a local web server, just ask, there's quite a few of them available, many which can be run at the command line.