[英]How to implement password protected PDF file in iPhone SDK
是否有人知道如何在iphone sdk中實現受密碼保護的PDF文件。 我的意思是我需要從我的應用程序創建一個密碼pdf文件。請幫助我。
任何人的幫助將不勝感激。
這是另一種可能更適合您的解決方案:
CGPDFContextCreate采用一個字典,您可以在其中傳遞密碼作為其中一個屬性。
有關CGPDFContxtCreate的詳細信息,請參閱Apple的參考文檔:
您可以在Apple的文檔中找到密碼設置信息:
我們可以使用以下方式提供PDF文件的密碼:
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:@"owner", kCGPDFContextOwnerPassword, @"user", kCGPDFContextUserPassword, kCFBooleanFalse, kCGPDFContextAllowsCopying, kCFBooleanFalse, kCGPDFContextAllowsPrinting, nil];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileName = [NSString stringWithFormat:@"%@/Documents/samplePDF.pdf", NSHomeDirectory()];
if (![fileManager fileExistsAtPath:fileName]) {
[fileManager createFileAtPath:fileName contents:nil attributes:nil];
}
// Create the PDF context using the default page size of 612 x 792.
UIGraphicsBeginPDFContextToFile(fileName, CGRectZero, dictionary);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.