Filter RMS Protected PDF Files

RMS-protected PDF files have two parts. The first is an unencrypted "outer" PDF, which contains standard text stating that the document is protected. The second is an encrypted "inner" PDF, which is attached to the outer PDF and contains the actual content.

To filter both parts separately, filter the outer PDF and then extract the inner PDF and filter that. Alternatively, to ignore the boilerplate text in the outer PDF and process both parts together as if the content were contained in the "outer" file, follow these steps.

To process an RMS-encrypted PDF as if it were a single file

  1. For any incoming document, call fpGetDocInfoFile or fpGetDocInfoStream from the Filter API. If the ADDOCINFO has eFormat equal to PDF_Fmt, and the kWindowRMSEncrypted flag is not set in ulAttributes, then the document could be an unencrypted outer PDF for an RMS-encrypted PDF. Otherwise, treat the document as normal and skip the remaining steps.
  2. Call fpOpenFile then fpGetMainFileInfo from the Extract API. If the KVMainFileInfo shows that the document has one subfile (numSubFiles equal to one), the document could be an unencrypted outer PDF for an RMS-encrypted PDF. Otherwise, treat the document as normal and skip the remaining steps.
  3. Call fpGetSubFileInfo for the sub file. If the KVSubFileInfo has subFileName equal to MicrosoftIRMServices Protected PDF.pdf, the sub file could be an RMS-encrypted PDF. Otherwise, treat the document as normal and skip the remaining steps.
  4. Call fpExtractSubFile or fpOpenSubFile to extract or open the subfile.
  5. Call fpGetDocInfoFile or fpGetDocInfoStream on the extracted subfile. If the ADDOCINFO has eFormat equal to PDF_Fmt, and the kWindowRMSEncrypted flag is set in ulAttributes, then the sub file is the inner RMS-encrypted PDF for the original document. Otherwise, treat the document as normal and skip the remaining steps.
  6. Treat this extracted sub file as if it were the original document - filter, get metadata from, and extract subfiles from this sub file instead of the original document.