title: How to decode PDF binary data to Postscript readable text
body: <p>I'm currently searching for a way to extract the code (PostScript) behind a PDF just from its binary data.
  I have an input of type file that has an onChange event handler attached. The event handler looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>
  const handleFileChange = (e) =&gt; {
    const [file] = e.target.files
  
    const reader = new FileReader()
    
    reader.addEventListener(&quot;loadend&quot;, () =&gt; {
      const buffer = reader.result
      const view = new DataView(buffer)
      
      const decoder = new TextDecoder(&quot;ascii&quot;)
      const text = decoder.decode(view)
    })
    
    reader.readAsArrayBuffer(file)
  }
  
  </code></pre>
  <p>This code produces text that looks like this <code>%PDF-1.3 %Äåòåë§ó ÐÄÆ 3 0 obj &lt;&lt; /Filter /FlateDecode /Length 4573 &gt;&gt; stream xµ\ëŽÜ¶þÏ§ Ð¶Vwi‚ hìM</code>
  The beginning is just fine, it's everything afterward is the issue - <code>%Äåòåë§ó ÐÄÆ</code> &amp; <code>µ\ëŽÜ¶þÏ§ Ð¶Vwi‚ hìM</code>. It's illegible. I'm not sure if I just have the wrong <a href="https://encoding.spec.whatwg.org/#the-encoding" rel="nofollow noreferrer">encoding</a> selected or what I'm setting out to do is all but impossible. Am I missing something here? If yes, what exactly?
  I appreciate any and all help. Thank you!</p>
  <p>(<strong>resources are also welcomed</strong>)</p>