The OpenSSL S/MIME command can extract the contents of a .p7m CAdES file.
If your signed file is named MyDocument.pdf.p7m, to extract its contents as MyDocument.pdf, run:
openssl smime -verify -noverify -binary -in MyDocument.pdf.p7m -inform DER -out MyDocument.pdf
Each of the given options is needed for the following reasons:
-verify to extract the signed data;
-noverify instructs -verify to only extract the contents, skipping the signature verification; without it, the command would fail and print: Verification failure;
-binary is required if the contained document is not a plain text file, otherwise the output may be corrupted;
-inform DER tells the tool about the input file format; otherwise, the command fails with: Error reading S/MIME message;
and, finally:
-in and -out specify respectively the input .p7m file (which must exist) and the output contents file (which will be created).
Update
A more suitable command is OpenSSL CMS, specifically designed for CAdES.
It supports the same options:
openssl cms -verify -noverify -binary -in MyDocument.pdf.p7m -inform DER -out MyDocument.pdf