AuraDoc
Sign inSign up

What is JavaScript in a PDF?

PDF files can contain small JavaScript programs that the reader runs when certain events happen, for example when the document opens, a page is shown or a form field changes. The scripts are written in the same language used on websites, but run inside the PDF reader with a special set of document functions. Most readers warn or ask before running them.

Legitimate uses

Most PDF JavaScript is harmless and practical. Interactive forms use it to calculate totals, check that a date or number has the right format, show or hide fields depending on an answer, or fill one field from another. Some documents use it to print automatically or open at a certain page. Without the script, these forms still show their fields, but the automatic calculations and checks stop working.

Security risks

Scripts are also a common way to attack readers. A malicious PDF can use JavaScript to exploit flaws in older reader software, open web addresses or hide content. For this reason many organisations disable JavaScript in their PDF readers, email filters flag PDFs with scripts, and the PDF/A archiving standard forbids JavaScript completely, so an archived file can never change its own content.

Removing scripts

Removing JavaScript deletes the document-level and form scripts while leaving the pages, text and images intact. It is a good step before sharing a file outside your organisation, before archiving it, or when a portal rejects the upload. If the PDF is a calculating form, fill it in first and remove the scripts afterwards, so the computed values are kept.

Tools that use this

Guides that put it into practice

Common questions

How do I know whether a PDF contains JavaScript?
Some readers show a warning or ask for permission to run scripts. A sanitiser or script remover also reports what it found. If you did not expect scripts in a document, treat the file with caution.
Will removing JavaScript break my form?
The fields remain and can still be filled, but automatic calculations, format checks and show-hide rules no longer run.
Does converting to PDF/A remove JavaScript?
Yes. PDF/A forbids scripts, so a correct conversion leaves them out of the archived file. Interactive forms in the archived copy keep their visible values but no longer calculate.

Side-by-side comparisons

Related terms

Need more than a quick fix?

AuraDoc is a document platform with OCR, AI search and summaries, and more than 60 PDF tools for teams. Try it free for 7 days.

Tools marked “Secure server” send your file once, over an encrypted connection, to an isolated AuraDoc server. It is processed in a throw-away process and deleted as soon as the result is sent back. Fair use and anti-abuse policy