<p>you can open the file directly from the url and then work on it as a pdf by using <code>urllib.request</code> :</p>
<pre><code>import pdftotext
from urllib.request import urlopen

target_url = &quot;https://arxiv.org/pdf/2012.05439.pdf&quot; #  to change.
file = urlopen(target_url)

pdf = pdftotext.PDF(file) # add password if password protected.

# How many pages?
print(len(pdf))

# Iterate over all the pages
for page in pdf:
    print(page)

# Read some individual pages
print(pdf[0])
print(pdf[1])

# Read all the text into one string
print(&quot;\n\n&quot;.join(pdf))
</code></pre>
how to read pdf from url using pdftotext
<p>I want to read two PDF files from URL without download. Then I want to extract text using pdftotext</p>
<pre><code>import pdftotext


with open(&quot;pdf_path1&quot;, &quot;rb&quot;) as f:
    pdf = pdftotext.PDF(f)

# If it's password-protected
with open(&quot;b.pdf&quot;, &quot;rb&quot;) as f:
    pdf = pdftotext.PDF(f, &quot;secret&quot;)

# How many pages?
print(len(pdf))

# Iterate over all the pages
for page in pdf:
    print(page)

# Read some individual pages
print(pdf[0])
print(pdf[1])

# Read all the text into one string
print(&quot;\n\n&quot;.join(pdf))
</code></pre>
<p>How can I resolve this error? or is there any other technique available to read PDF from URL?</p>