title: How to remove open actions and javascript from pdf
body: <p>Is there a way to quickly remove <code>open actions</code> and <code>javascript</code> from <code>pdf</code>s (without damaging/affecting the contents)?</p>
  
  <p>I download <code>pdf</code>s regularly and often see messages like this:</p>
  
  <p><a href="https://i.stack.imgur.com/a3vz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a3vz8.png" alt="enter image description here"></a></p>
  
  <p>when scanning the <code>pdf</code> with <a href="https://www.virustotal.com/#/home/upload" rel="nofollow noreferrer">virustotal</a>. What would be great is if there is a way to quickly remove <code>open actions</code> and <code>javascript</code> from the <code>pdf</code> (from say, a CLI command, online interface, or python script) (or at least see the code that the <code>pdf</code> intends to run, have tried using a text editor to look for <code>/JS</code> or <code>/JavaScript</code> text in <code>pdf</code>s but the content seems like something garbled that I can't interpret). </p>
  
  <p>Currently, using Mac Preview, I <code>export as pdf</code> to get rid of some of these things, but it does not always work. Have also tried <a href="https://security.stackexchange.com/q/103323">this</a> solution, but often can't open the <code>.postscript</code> that it generates.</p>
  
  <p>I understand that Mac Preview does not support javascript, but I often would like to transfer these files to other people on other OSs and these <code>open actions</code> and <code>javascript</code> makes me nervous for their computers. </p>
  
  <p>Don't know much about computer security or pdf structures, so any suggestions and advice would be appreciated. Thanks. </p>