Google Answers Logo
View Question
 
Q: Removing Javascript from a PDF document. ( Answered,   0 Comments )
Question  
Subject: Removing Javascript from a PDF document.
Category: Computers > Software
Asked by: humatrope-ga
List Price: $4.00
Posted: 10 Feb 2003 23:02 PST
Expires: 12 Mar 2003 23:02 PST
Question ID: 159827
How can I remove Javascript from a PDF document?  When I try via the
console, I get the message "you can't edit XML tags"  There is also
references to Acrobat EScript and ECMAScript.  I am not the original
author of this document, it is unencrypted.

Request for Question Clarification by maniac-ga on 11 Feb 2003 16:52 PST
Hello Humatrope,

Are you trying to do this with a specific application or system
(perhaps Adobe Acrobat)? Please indicate which tool you are using /
specific error messages you get to help search for a solution.

If you don't mind to do a little experimentation, a technique that may
work is to
 1 open the pdf file with a plain text editor
 2 search for javascript
 3 remove the block around that phrase or replace it with blanks - it
is pretty obvious where the Javascript is
 4 repeat 2 & 3 until all the javascript is gone
 5 save the file
For example, looking at
  http://www.documents.dgs.ca.gov/osp/pdf/std020.pdf
which has a Javascript enabled form, the Javascript is near the end of
the file. At least my test did not break the file (it still looks OK).

  --Maniac

Request for Question Clarification by maniac-ga on 19 Feb 2003 16:28 PST
Hello Humatrope,

Are you still interested in a solution for this problem or have you
solved it with the information already provided?

  --Maniac

Clarification of Question by humatrope-ga on 20 Feb 2003 10:58 PST
Sorry for the delay Maniac, still haven't solved it.  How do determine
exactly *what* to trim?  Thanks
Answer  
Subject: Re: Removing Javascript from a PDF document.
Answered By: maniac-ga on 20 Feb 2003 17:44 PST
 
Hello Humatrope,

Determining what to trim comes from a brief review of the relevant
Adobe specifications. I will assume the use of a text editor that will
not "damage" the file (just apply your changes and will not make other
changes to the file to "help" you).

According to the Adobe PDF Specification, page 556 (576 of 978)
  http://partners.adobe.com/asn/developer/acrosdk/docs/filefmtspecs/PDFReference.pdf
describe Javascript actions. The table on this page indicates in part:
  JS string or stream (Required) A string or stream containing the
JavaScript script to be executed.
Note: PDFDocEncoding or Unicode encoding (the latter identi?ed by the
Unicode
pre?x U +FEFF) is used to encode the contents of the string or stream.
(See implementation
note 89 in Appendix H.)

Using the same example as I provided above, in text form it looks
like...
  264 0 obj
  << 
  /S /JavaScript 
  /JS (encoded characters here)
  >> 
  endobj
Using this example, the only places where the phrase /JS appears is in
objects such as this one. The characters within the parenthensis are
the javascript (in a form that is not readily read by the user).
Eliminate them to eliminate the Javascript.

As a cross check, search the document repeatedly for 264. It appears
in a larger number, but also appears inside an "Annot" (annotation)
and "widget"; object 194. You could continue to go back to find
further references of this type (to 194).

So at this point - the Javascript appears to be within the
parenthensis, as an encoded string. Remove those strings; save the
file; review the result. This should result in removal of the
javascript from the file.

If this is unclear or not complete - please don't hesitate to ask for
clarification.

  --Maniac
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy