File Conversions

P7M to PDF: How to Open a Signed .p7m File and Get the PDF Inside

A .p7m file is a digital signature wrapped around another file. Here's how to unwrap it on Windows, Mac or Linux, and how to tell when it's encrypted instead.

Alex Petrov · February 11, 2026

Abstract circuit-board style cover in navy, orange and yellow, for a guide to converting P7M to PDF

To get from P7M to PDF, you usually don't convert anything: a .p7m file is a digital signature wrapped around the original file, and you only have to unwrap it. A file named contract.pdf.p7m holds contract.pdf, and a signature reader or one OpenSSL command gets it out unchanged.

The exception is an encrypted file, often an email attachment named smime.p7m. That one needs the recipient's private key, so no converter can open it.

What a P7M File Is

P7M is a file format from the PKCS #7 standard, also known as the Cryptographic Message Syntax. It wraps a file in a signed envelope, an encrypted one, or both.

You'll meet two kinds:

  • A signed document, like invoice.xml.p7m or contract.pdf.p7m. The original file is inside, readable, with the signer's certificate and signature attached. Italy uses these for qualified digital signatures and electronic invoices.
  • An encrypted file, often an email attachment. It's locked with the recipient's certificate, and only their private key opens it.

The name smime.p7m doesn't settle it. RFC 8551 uses .p7m for signed data as well as encrypted data, and recommends the base name smime for any S/MIME entity, so a smime.p7m can be signed only. This command prints the kind, on its second line, as pkcs7-signedData or pkcs7-envelopedData:

1openssl asn1parse -inform DER -in smime.p7m

How to Open a Signed P7M File as a PDF

The usual way is a free signature verification program. Italy's AgID names GoSign, ArubaSign, Firma OK!, Namirial Sign and DigitalSign Reader among others, on a page last updated in September 2021.

Those programs verify a signature. Check your program's help for saving the document inside.

If you'd rather use the command line, OpenSSL can unwrap the file. Our Mac already had it at /usr/bin/openssl, our Linux container had it too, and the OpenSSL project's wiki lists Windows installers.

  1. Open Terminal (Mac, Linux) or a command prompt with OpenSSL (Windows) in the folder with the file.
  2. Run the command below, with your own file names.
  3. Open contract.pdf: it's the original document, byte for byte.
1openssl cms -verify -noverify -binary -inform DER -in contract.pdf.p7m -out contract.pdf

-noverify skips checking the signer's certificate, so a good result says nothing about who signed. For that, use a signature reader that trusts the right certificate authorities. OpenSSL's docs say the older openssl smime command has no CMS support, so we use cms.

What We Got From OpenSSL on Our Own Signed Files

The command got an identical copy out of every intact file with its document inside: each output matched the original's SHA-256. In November 2026 we signed a PDF and an XML file with a self-signed certificate, using cms -sign -cades -nodetach -binary, then extracted them with OpenSSL 3.5.7 in a Linux container and LibreSSL 3.3.6, the openssl on our Mac. These aren't qualified signatures, so a real invoice may differ.

Test fileResult
Signed PDF or XML"Verification successful", identical output
Signed with a certificate that expired in 2021Still extracted with -noverify, identical output. Without it: "certificate has expired"
One content byte changed"Verification failure", but the output file was still written, with the changed byte
Signature only, no document inside"no content", empty output
Encrypted"content type not signed data" in OpenSSL, "wrong content type" in LibreSSL, empty output

So an expired certificate doesn't stop you getting the document out. Read the message, not just whether a file appeared: after a failure, delete the output and go back to the sender.

If you get a "wrong tag" error, the file is probably Base64 text and not binary. A file with a BEGIN CMS or BEGIN PKCS7 line works with -inform PEM. Plain Base64 with no such line needs decoding first with openssl base64 -d -in file.p7m -out file.der (add -A if the Base64 is one long line), and then the command above on file.der.

When the File Inside Isn't a PDF

A signed .p7m can hold any file. Once it's unwrapped, convert the result:

  • A Word document (.docx.p7m) goes through Word to PDF, and our guide to fonts and formatting in Word to PDF helps if the layout shifts.
  • An Italian electronic invoice (.xml.p7m) is XML; our guide to converting XML to PDF covers the ways to print it readably. FatturaPA's site publishes the stylesheets valid from April 1, 2025: FatturaPA 1.2.3, Fattura Ordinaria 1.2.3 and Fattura Semplificata 1.0.2.
  • A TXT file goes through TXT to PDF.

How to Open an Encrypted smime.p7m Email

An encrypted email can only be opened with the private key of the certificate it was encrypted for, as Microsoft's S/MIME page says too. No converter can get around that.

  1. Make sure your S/MIME certificate is installed on the computer (your IT department or certificate provider gives you this).
  2. Open the message in a mail program set up with that certificate.
  3. Open the attachment you need and print it to PDF. On Windows choose Microsoft Print to PDF as the printer, on a Mac open the PDF menu and choose Save as PDF.

For a message you can open, our guide to saving an email as PDF in Outlook has the print steps. Mail stuck in an old Outlook .ost file is a different problem, covered in our guide to converting OST to PDF without Outlook.

Should You Use an Online P7M to PDF Converter?

Several online services offer to convert P7M files, and none of them can open an encrypted one without your key.

The pdfFiller page Convert P7M to PDF online For Free with its upload box, an example of an online P7M to PDF converter

OpenSSL unwraps a signed file on your own computer, so we'd keep contracts and invoices offline. We don't offer a P7M converter on pdf-file.com.

What to Do With the PDF Afterwards

The extracted PDF no longer carries the P7M signature, so keep the original .p7m file if you need proof of who signed it.

The pdf-file.com All PDF Tools menu with Merge PDF, Remove Pages, Compress PDF and Protect PDF highlighted, tools for the PDF you got from the P7M file
  • Too big to email? Shrink it with Compress PDF.
  • Part of a bigger file? Join it with others in Merge PDF.
  • Confidential? Add a password with Protect PDF before you pass it on.
The pdf-file.com Protect PDF upload page with the Choose Files button, for adding a password to the PDF taken out of a P7M file

Frequently Asked Questions about P7M to PDF

Can I just rename .p7m to .pdf?

Don't rely on it. On our renamed test file, qpdf reported a damaged file, while Poppler's pdfinfo still read it. Unwrap it instead.

Is the extracted PDF still digitally signed?

Not by the P7M signature: that stays in the .p7m file. Keep both files if you might need to prove the signature later.

Why can't I open a smime.p7m email attachment?

If it's encrypted, only the holder of the private key can open it. If it's signed only, it unwraps like any other .p7m. The asn1parse command above tells you which.

Try it on your own file