Skip to content

Commit

Permalink
Adds notes concerning opening remote files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie-lemon committed Jul 18, 2024
1 parent 2326df6 commit ee22f01
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/how-to-open-a-file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,40 @@ Assume that *"some.file"* is actually an **XPS**. Open it like so:
If you attempt to open an unsupported file then |PyMuPDF| will throw a file data error.




----------


Opening Remote Files
~~~~~~~~~~~~~~~~~~~~~~~~~~


For remote files on a server (i.e. non-local files), you will need to *stream* the file data to |PyMuPDF|.

For example use the `requests <https://requests.readthedocs.io/en/latest/>`_ library as follows:

.. code-block:: python
import pymupdf
import requests
r = requests.get('https://mupdf.com/docs/mupdf_explored.pdf')
data = r.content
doc = pymupdf.Document(stream=data)
Opening Files from Cloud Services
""""""""""""""""""""""""""""""""""""""

For further examples which deal with files held on typical cloud services please see these `Cloud Interactions code snippets </~https://github.com/pymupdf/PyMuPDF-Utilities/tree/master/cloud-interactions>`_.



----------



Opening Files as Text
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit ee22f01

Please sign in to comment.