Copy link to clipboard
Copied
I'm running into an issue where I cannot preview a local pdf.
I have tried:
adobeDCView.previewFile(
{
content: {location: {url: "file:///C:/my/sandbox/local_file.pdf"}},
metaData: {fileName: "local_file.pdf"}
}, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
});
and
adobeDCView.previewFile(
{
content: {location: {url: "local_file.pdf"}},
metaData: {fileName: "local_file.pdf"}
}, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
});
But 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.
Copy link to clipboard
Copied
Hi, Thanks for using View SDK, Browsers generally disallow accessing files from the local file system using file path even if the HTML is also on the local file system for security reasons.
Although there is a possible solution to your problem is to use SimpleHTTPServer.
Below snippet will work in this case.
adobeDCView.previewFile(
{
content: {location: {url: "local_file.pdf"}},
metaData: {fileName: "local_file.pdf"}
}, {embedMode: "IN_LINE", showDownloadPDF: true, showPrintPDF: true});
I hope this helps!
Copy link to clipboard
Copied
Hi Shubhanshu,
Thank you for your help! I tried your suggestion but am encountering issues.
Running my Python http server worked fine. And I'm able to see:
http://localhost:8000/local_file.pdf
But when I try to view, I get this View SDK error:
File preview not available
Domain http://localhost is invalid
Can you please advise? Thank you!
---
PS. Here are screenshots of the errors I'm receiving:
-----
Update (6/1): I tried one more thing tonight that didn't work-- I tried opening index.html locally (not running on Python's http.server) and when I tried to view my PDF (that is being served on localhost:8000), I now see this error:
Can you please advise? Thank you!
Copy link to clipboard
Copied
Hi, Ideally it should allow localhost to be added. We are working on that.
Meanwhile, you can try generating client id by https://www.adobe.io/apis/documentcloud/dcsdk/gettingstarted.html
and provide domain as localhost.
Copy link to clipboard
Copied
Ah, okay-- I see. Creating a "localhost" clientId (API key) works from here:
but fails (is disallowed) from inside of https://console.adobe.io/
That's a bit confusing. I've got my sandbox project working now though; thank you for helping!