# Open .pdf, .txt, .docx, etc documents from a list of paths

**URL:** <https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400>\
**Category:** Dash Python\
**Created:** [August 3, 2023, 3:08am UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400 "2023-08-03T03:08:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamwirono](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@williamwirono](https://community.plotly.com/u/williamwirono)\
**Post date:** [August 3, 2023, 3:08am UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/1 "2023-08-03T03:08:59Z")

</div>

I have a list of document paths listed in Dash. I want to make the document paths clickable so that users can open the documents by clicking the document paths. For instance, if the path is a .docx document, the user’s default .docx program should pop up. Is there a way to do this in Dash?

I tried using dcc.Link with the href parameter as the filepath. I also tried using html.A with the href parameter and target=‘\_blank’. Both didn’t work unfortunately. I got the following error:

react-dom@16.v2\_9\_3m1685119029.14.0.min.js:32 Uncaught DOMException: Failed to execute ‘pushState’ on ‘History’: A history state object with URL ‘file:///C://…’ cannot be created in a document with origin ‘[http://127.0.0.1:8080](http://127.0.0.1:8080)’ and URL ‘http:127.0.0.1:8080/’.

Not sure if this is the right way to go or if there is a better route. Any help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [August 3, 2023, 5:25pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/2 "2023-08-03T17:25:18Z")

</div>

Hello @williamwirono,

I dont think that you can make it happen by default, it would have to be defaulted on each computer what to do with a downloaded document.

You can allow a download of the object with a dcc.Download, other than that, typically controlling a computer from a browser is a no-no due to viruses/malware/etc. 🙂

---

<div class="post-metadata">

**Author:** ![williamwirono](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@williamwirono](https://community.plotly.com/u/williamwirono)\
**Post date:** [August 3, 2023, 5:49pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/3 "2023-08-03T17:49:11Z")

</div>

@jinnyzor Hmm gotcha. I am a bit reluctant in making it as a download feature since the user has already had those files in their system. I just wanted to open the file in that path. But anyways, thanks for the input! If you think of something as you go, please do reach out!

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [August 3, 2023, 5:54pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/4 "2023-08-03T17:54:53Z")

</div>

If the user already has the folder, you can hard code it.

I believe the path for a file is something like:

```auto
file://

```

> <https://stackoverflow.com/questions/1254572/cross-browser-link-to-file-on-local-system>

---

<div class="post-metadata">

**Author:** ![williamwirono](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@williamwirono](https://community.plotly.com/u/williamwirono)\
**Post date:** [August 4, 2023, 7:32pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/5 "2023-08-04T19:32:21Z")

</div>

@jinnyzor I tried this, and it gave me the following error in the Console: ‘Not allowed to load local resource.’ Has this got something to do with the browser’s security settings?

---

<div class="post-metadata">

**Author:** ![williamwirono](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@williamwirono](https://community.plotly.com/u/williamwirono)\
**Post date:** [August 4, 2023, 7:58pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/6 "2023-08-04T19:58:19Z")

</div>

Nevermind, got it to work in Chrome. You will need to install a Chrome Extension called ‘Enable local file links’ to allow links to local files that was disabled by Chrome by default.

---

<div class="post-metadata">

**Author:** ![jinnyzor](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jinnyzor/32/21194_2.png) [@jinnyzor](https://community.plotly.com/u/jinnyzor)\
**Post date:** [August 4, 2023, 8:00pm UTC](https://community.plotly.com/t/open-pdf-txt-docx-etc-documents-from-a-list-of-paths/77400/7 "2023-08-04T20:00:49Z")

</div>

I believe it is regularly disabled…

I dont know if you could skirt around this with having an `onclick` function that forces the browser to open a new window at that location.
