Is there a tool (or command) to indicate if a PDF file contains JavaScript?

Hello Friends

According with your experience

Is there a tool (or command) to indicate if a PDF file contains JavaScript?

Of course, it to be aware before to open the file

Thanks in advance

2 Likes

@Manuel_Jordan :

Hi Manuel, :waving_hand:

the command pdfinfo should do the job. It´s part of the package poppler-utils.

I just tried it out on a PDF file (Gesamtwirtschaftsplan_2026.pdf ) residing on my system:

pdfinfo Gesamtwirtschaftsplan_2026.pdf 
Producer:        GPL Ghostscript 9.55.0
CreationDate:    Wed May 28 17:36:03 2025 CEST
ModDate:         Wed May 28 17:36:03 2025 CEST
Custom Metadata: no
Metadata Stream: yes
Tagged:          no
UserProperties:  no
Suspects:        no
Form:            none
JavaScript:      no
Pages:           2
Encrypted:       no
Page size:       1530 x 2039.76 pts
Page rot:        0
File size:       967603 bytes
Optimized:       no
PDF version:     1.7

It says:
JavaScript: no

You don´t have to open the file for that. Just provide it as an argument to the command, like in my example.

Hope it helps.

Many greetings from Rosika :slightly_smiling_face:

P.S.:

If you don´t have it on your system already, you have to install the package first.
E.g. for DEB-based systems:

sudo apt-get install poppler-utils

7 Likes

Hello Rosika!

Huge thanks for the support :slight_smile:

Just being curious What does the Suspects term mean?
It appears in the report

3 Likes

@Manuel_Jordan :

Hi Manuel, :waving_hand:

you´re welcome.

To be honest, I was using this command for the same purpose as you do.
Just wanted to know about the Java Script part.

But that´s an interesting question of yours.
I tried to research it and came up with the following findings:

The “Suspects: no” line in the output of the pdfinfo command seems to refer to a property related to Tagged PDFs.
As you may notice in my example there´s also the line:

Tagged: no

Accordingly to me it seems logical that Suspects says “no” as well.

Generally speaking the “Suspects” line indicates whether the PDF contains any “suspect” tags or elements that might be problematic or doubtful in the tagging structure of the document.

In my case it means the PDF does not have any suspect or questionable tagging elements in its structure.

Hope it helps.

Many greetings from Rosika :slightly_smiling_face:

5 Likes

Hello Rosika

To be honest, I was using this command for the same purpose as you do.
Just wanted to know about the Java Script part.

Ok, we are in the same channel :nerd_face:

But that´s an interesting question of yours.
I tried to research it and came up with the following findings:

Soon as I can I am going to research the man command for that command

The “Suspects: no” line in the output of the pdfinfo command seems to refer to a property related to Tagged PDFs.
As you may notice in my example there´s also the line:
Tagged: no
Accordingly to me it seems logical that Suspects says “no” as well.

And now what does the tagged term mean in PDF? :laughing:

Generally speaking the “Suspects” line indicates whether the PDF contains any “suspect” tags or elements that might be problematic or doubtful in the tagging structure of the document.

Is important know the relation of both terms

Best!

2 Likes

@Manuel_Jordan :

Hi Manuel, :waving_hand:

Good question. Once again I had to do a bit of research on that.
But I´d like to know that as well.

I found out that Tagged PDF refers to a PDF file that includes structural information about the document content.

This structure is added using tags that define the logical reading order and the role of different elements: These could be e.g. headings, paragraphs, lists, tables, etc.

It seems that screen readers and other assistive technologies rely on these tags to interpret and present the content correctly. So they are really important for those applications.

So Tagged: no basically says: the PDF does not contain tagging information.

If I understood it correctly both “Tagged” and “Suspects” are properties related to the PDF’s tagging structure, which is used for accessibility and logical document structure.

  • “Tagged: no” means the PDF does not contain any tagging information; it is not a tagged PDF

  • Suspects: no" means there are no suspect (potentially problematic or questionable) tags present in the PDF’s tagging structure

  • The “Suspects” property is only meaningful if the PDF is tagged. If “Tagged: no,” then “Suspects: no” simply indicates that, since there are no tags, there can’t be any suspect tags either.
    That´s why is said:

… in my post #4.

I hope I got it all correct. :wink:

Many greetings from Rosika :slightly_smiling_face:

4 Likes