Yes. A PDF can contain JavaScript, other files attached inside it and links to websites, and attackers use these to deliver malware or send you to a fake login page. Word, Excel and PowerPoint files can carry macros, small programs that run inside Office. Keep your PDF reader and Office updated, be wary of unexpected attachments, and look inside a file before you open it. A file check is not antivirus, though, and a clean result doesn't prove a file is safe.
Can PDF files contain viruses?
Yes. A PDF can hold more than the pages you see:
- JavaScript, which PDF readers can run for things like form calculations, and which attackers can misuse
- other files attached inside the PDF, such as a document, a ZIP or a program
- links and buttons that open a website, often a fake login page
- actions that run when the file opens
Security people usually call this PDF malware rather than a virus, but the worry is the same.
Can you get a virus from opening a PDF?
It's possible, but most attacks need help from somewhere else: an out-of-date PDF reader with a known flaw, or you clicking a link, opening an attached file or allowing a script. That's why CISA, the US cybersecurity agency, starts its tips on email attachments with two habits: confirm unexpected attachments with the sender, and keep your software updated.
PDFs are also the most common phishing attachment. Hoxhunt, a company that trains staff to spot phishing, says PDFs made up 23.7% of attachment-based phishing reported to it in the first half of 2025.
Can Word, Excel and PowerPoint files have viruses?
Yes, and macros are the classic way in. A macro is a small program saved inside an Office file. Files ending in .docm, .xlsm and .pptm are made to hold them, and older .doc, .xls and .ppt files can too.
Microsoft changed the default in 2022. Office on Windows now blocks macros in files from the internet and shows a "Security Risk" banner with no button to enable them. Phishing emails often try to talk you around this with steps to unblock the file. If an attachment comes with instructions for turning off a security warning, that's the warning sign.
Office files can also link to things outside the file: other workbooks, pictures loaded from a website, or files on someone's computer. These are usually innocent, but a link you didn't expect is worth a look.
What to look for before you open an attachment
| Sign | Why it matters |
|---|---|
| You weren't expecting it | Most attacks arrive as a surprise "invoice", "voicemail" or "document to sign" |
| The PDF contains JavaScript | Rare in ordinary documents outside forms |
| The PDF has files attached inside it | A PDF that carries a program or ZIP has no innocent reason to |
| A macro-enabled Office file (.docm, .xlsm, .pptm) | Can run code once macros are on |
| It asks you to enable content, unblock or log in | The attack needs your help |
| A QR code or "view document" link instead of content | Takes you to a website, often a fake login page |
How to look inside a PDF or Office file first
- Drop the file into our metadata checker. It reads the file in your browser without opening it in Word or Acrobat, and nothing is uploaded. For PDFs it flags JavaScript and files attached inside. For Office files it lists embedded files, links to other workbooks and links to files on the author's computer.
- For a closer look at a PDF, the PDF metadata remover shows the names of attached files and can remove them along with other hidden content.
- If something looks off, confirm with the sender through another channel, such as a phone call, before you open the file in your usual app.
A file that hides text for AI tools is another warning sign; see hidden AI prompts in files.
What a file check can't tell you
Whether the file is safe. Our checker isn't antivirus. It doesn't compare files with known malware, it doesn't run them, and it can't see inside password-protected or encrypted parts. A file with no scripts or attachments can still lead you to a fake website, and a scammer can send a perfectly clean PDF with a fake bank number on it, as covered in how to spot a fake invoice.
So use it to decide whether to look closer, and keep the basics on: an updated PDF reader and Office, your email provider's attachment scanning, and antivirus software. This guide is general information, not security advice.