title: PDF JavaScript deletePages
body: <p>I'm working on a stupid hack to make it harder for users in my org to "save" certain pdfs when they're loaded in a browser window.  The best I can think of (other than using certificate encryption, which isn't an option right now) is to create a "Will Save" event and delete all pages in the document before it's saved.</p>
  
  <p>Based on the <a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf" rel="nofollow">PDF Javascript API</a> this should be pretty easy.</p>
  
  <pre><code>//-------------------------------------------------------------
  //-----------------Do not edit the XML tags--------------------
  //-------------------------------------------------------------
  
  //&lt;Document-Actions&gt;
  //&lt;ACRO_source&gt;Document Will Save&lt;/ACRO_source&gt;
  //&lt;ACRO_script&gt;
  /*********** belongs to: Document-Actions:Document Will Save ***********/
  this.deletePages(0, this.numPages - 1);
  //&lt;/ACRO_script&gt;
  //&lt;/Document-Actions&gt;
  </code></pre>
  
  <p>However, when I hit save, I get the following error.  This happens even if I just do <code>this.deletePages(0, 0)</code> or any other combination of numbers.  Does anyone have any idea what stupid error I might be making?</p>
  
  <pre><code>TypeError: Invalid argument type.
  Doc.deletePages:1:Document-Actions:Document Will Save
   ===&gt; Parameter nEnd.
  </code></pre>
  
  <p>Side note, I found another way of "solving" this, which is to call <code>this.closeDoc()</code> in the Will Save event.  This causes the browser and adobe to crash (it works!  but at what cost?).</p>