Showing posts with label decrypt. Show all posts
Showing posts with label decrypt. Show all posts

Tuesday, 25 September 2012

ColdFusion IceBreaker #7 : Unprotect your protected PDF through CF

Protecting your PDF with a password is a common everyday use case .
Using ColdFusion this can be done in a single easy step.

But sometimes we need to programmatically de-crypt/un-protect the same PDF.
There can be various ways of accomplishing this feat,but again ColdFusion makes it easy and a single step process

The trick to get to the treat ( the un-protected pdf , in this case ) is to use cfpdf tag and set your encyption to none using the "encrypt" attribute. You can do so only if you have the owner password , as technically only the document owner should have the permissions to change the security settings of a document

So assuming your PDF is called MyPdf.pdf with a owner password of "changesettings",use the below mentioned code to remove password protection from your PDF

<cfpdf action="protect" source="MyPdf.pdf" destination="MyUnsafePdf.pdf" 
password="changesettings" encrypt="none" />

Open MyUnsafePdf.pdf and you have your pdf without password protection