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
- For any incoming document, call fpGetDocInfoFile or fpGetDocInfoStream from the Filter API. If the ADDOCINFO has
eFormat
equal toPDF_Fmt
, and thekWindowRMSEncrypted
flag is not set inulAttributes
, 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. - 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. - Call fpGetSubFileInfo for the sub file. If the KVSubFileInfo has
subFileName
equal toMicrosoftIRMServices Protected PDF.pdf
, the sub file could be an RMS-encrypted PDF. Otherwise, treat the document as normal and skip the remaining steps. - Call fpExtractSubFile or fpOpenSubFile to extract or open the subfile.
- Call fpGetDocInfoFile or fpGetDocInfoStream on the extracted subfile. If the ADDOCINFO has
eFormat
equal toPDF_Fmt
, and thekWindowRMSEncrypted
flag is set inulAttributes
, 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. - 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.