Re: How to know and open Password protected pdf (like preview)
Re: How to know and open Password protected pdf (like preview)
- Subject: Re: How to know and open Password protected pdf (like preview)
- From: Steve Christensen <email@hidden>
- Date: Sat, 27 Aug 2005 10:11:01 -0700
On Aug 26, 2005, at 2:06 PM, Dave Rehring wrote:
On 8/26/05 9:09 AM, Mradul Mandhanya at email@hidden wrote:
I want to open a password protected pdf file in my ImageView.
First how can I know that this pdf file is password protected?
and then how to unlock the file. I am writing app for Mac OS 10.3
and 10.4, So cannot use the pdf kit :-(
So tell me how can I achieve this?
Write your own PDF parser, that implements decryption and display?
License one?
Use an open-source project that supports it, respecting the license?
Well, if you're not adverse to mixing Carbon in with your Cocoa code,
you might be able to get what you need by using calls in
CoreGraphics/CGPDFDocument. It has support for dealing with encrypted
and locked documents and has been around since 10.2. Depending on what
you're doing, in might be possible to get the PDF document data into a
format that can be passed into Cocoa.
bool CGPDFDocumentIsEncrypted(CGPDFDocumentRef document);
bool CGPDFDocumentUnlockWithPassword(CGPDFDocumentRef document, const
char* password);
bool CGPDFDocumentIsUnlocked(CGPDFDocumentRef document);
You could then create a PDF document wrapper class that uses PDFKit on
10.4 and later, and then backs down to the CGPDFDocument calls on
earlier versions of the OS. That way only a small portion of your code
needs to deal with the messy details.
steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden