A user sent me a PDF that contains javascript. I would like to remove the Javascript to prevent possible attacks. Can I remove the Javascript using PHP or by another method? Any suggestion is appreciated.
First, to prevent possible attacks, you can disable javascript processing in Acrobat entirely. The method varies according to your version, but one such step-by-step guide can be found here: http://egyptianvulture.blogspot.com/2009/02/how-to-disable-javascript-in-acrobat.html
To remove javascript entirely from PDF documents programatically will take some research, unfortunately I can't offer any advice here except to search online. (I did so, and the results are sparse.)
You can remove javascript using a 3rd party application, such as Quick PDF Tools Pro, which is a $59 application. I don't know how successful it is, nor can I recommend it, but it is advertised as a feature. Caution: Password-protected PDF files likely will prevent such removal.