title: PDF.js with Google Apps Script
body: <p>I'm building a Google Docs plugin and I'm trying to pull a PDF from an external site to parse (for simple things like number of pages, text content, etc. that <strong>doesn't require visual rendering of the document</strong>). However, I've been having a lot of trouble integrating the Javascript library into my project.</p>
  
  <p>I understand that I will have to do some manual work to remove some stuff that are the parts that are browser-dependent, like DOM rendering or network connections. However, the error here is completely unrelated.</p>
  
  <p>I've tried manually copying all the source files into the project (changing the paths where required) <em>and</em> <a href="http://mozilla.github.io/pdf.js/build/pdf.js" rel="nofollow">using a "built" library I found online</a> (as just that one file in my project). However, I'm getting an odd syntax error whenever I save my project-</p>
  
  <blockquote>
    <p>Missing name after . operator. (line 1120, file "pdf")</p>
  </blockquote>
  
  <p>This is line 1120 in file "pdf":</p>
  
  <pre><code>if (typeof globalScope.Promise.prototype.catch !== 'function') {
  </code></pre>
  
  <p>This is a chunk of related code:</p>
  
  <pre><code>if (typeof globalScope.Promise.resolve !== 'function') {
    globalScope.Promise.resolve = function (value) {
      return new globalScope.Promise(function (resolve) { resolve(value); });
    };
  }
  if (typeof globalScope.Promise.reject !== 'function') {
    globalScope.Promise.reject = function (reason) {
      return new globalScope.Promise(function (resolve, reject) {
        reject(reason);
      });
    };
  }
  if (typeof globalScope.Promise.prototype.catch !== 'function') {
    globalScope.Promise.prototype.catch = function (onReject) {
      return globalScope.Promise.prototype.then(undefined, onReject);
    };
  }
  return;
  </code></pre>
  
  <p>However, no syntax errors that I can see <em>there.</em></p>
  
  <p>So, real question:</p>
  
  <ul>
  <li>There doesn't seem to be an apparent syntax issue. If there is one and I am overlooking that, what is that error?</li>
  <li>Otherwise, how can I find out where this issue originates? It seems like an odd, cascading issue.</li>
  </ul>