A way to preview a local PDF?

Community Beginner ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

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":

r002_0-1590777204894.png

 

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.

Views

281

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Did you ever work 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
Adobe Employee ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

LATEST

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.

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
Resources