<blockquote>
  <p>You Can try this code for checking remote server file exists or not by Url</p>
</blockquote>

<pre><code> $filename= 'arxiv.org/pdf/1207.4102.pdf';
    $file_headers = @get_headers($filename);

    if($file_headers[0] == 'HTTP/1.0 404 Not Found'){
          echo "The file $filename does not exist";
    } else if ($file_headers[0] == 'HTTP/1.0 302 Found' &amp;&amp; $file_headers[7] == 'HTTP/1.0 404 Not Found'){
        echo "The file $filename does not exist, and I got redirected to a custom 404 page..";
    } else {
        echo "The file $filename exists";
    }
</code></pre>
How to check whether pdf file exists?
<p>I am trying to check if pdf file exists in arXiv. There are two example</p>

<blockquote>
  <p><a href="http://arxiv.org/pdf/1207.41021.pdf" rel="nofollow noreferrer">arxiv.org/pdf/1207.4102.pdf</a> </p>
  
  <p><a href="http://arxiv.org/pdf/1207.41021.pdf" rel="nofollow noreferrer">arxiv.org/pdf/1207.41021.pdf</a></p>
</blockquote>

<p>The first is a pdf file and the second is not and returns an <a href="http://arxiv.org/pdf/1207.41021.pdf" rel="nofollow noreferrer">error page</a>.</p>

<p>Is there a way to check whether a url is pdf or not. I tried the answers in <a href="https://stackoverflow.com/questions/3646914/how-do-i-check-if-file-exists-in-jquery-or-javascript">How do I check if file exists in jQuery or JavaScript?</a> however none of them work and they return true (i.e. file exists) for both urls. Is there a way to find which url is pdf file in JavaScript/jQuery or even PHP? </p>

<p>Can this be solved using <a href="https://stackoverflow.com/questions/tagged/pdf.js">pdf.js</a>?</p>