【发布时间】:2015-08-11 06:05:14
【问题描述】:
我正在使用以下行来创建 PDF 参考:
**********CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateWithURL(theURL);**********
thePDFDocRef 返回 NULL,但在没有密码保护的文件的情况下加载也可以正常工作 ios 9 beta 5。
只有 ios 9 beta 5 有问题,但它适用于 ios 9 beta 4 及以下版本,如 ios 8、7、6 等...
CGPDFDocumentRef CGPDFDocumentCreateX(CFURLRef theURL, NSString *password)
{
CGPDFDocumentRef thePDFDocRef = NULL;
if (theURL != NULL) // Check for non-NULL CFURLRef
{
thePDFDocRef = CGPDFDocumentCreateWithURL(theURL);
if (thePDFDocRef != NULL) // Check for non-NULL CGPDFDocRef
{
if (CGPDFDocumentIsEncrypted(thePDFDocRef) == TRUE) // Encrypted
{
// Try a blank password first, per Apple's Quartz PDF example
if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, "") == FALSE)
{
// Nope, now let's try the provided password to unlock the PDF
if ((password != nil) && ([password length] > 0)) // Not blank?
{
char text[128]; // char array buffer for the string conversion
[password getCString:text maxLength:126 encoding:NSUTF8StringEncoding];
if (CGPDFDocumentUnlockWithPassword(thePDFDocRef, text) == FALSE) // Log failure
{
#ifdef DEBUG
NSLog(@"CGPDFDocumentCreateX: Unable to unlock [%@] with", theURL);
#endif
}
}
}
if (CGPDFDocumentIsUnlocked(thePDFDocRef) == FALSE) // Cleanup unlock failure
{
CGPDFDocumentRelease(thePDFDocRef), thePDFDocRef = NULL;
}
}
}
}
else // Log an error diagnostic
{
#ifdef DEBUG
NSLog(@"CGPDFDocumentCreateX: theURL == NULL");
#endif
}
return thePDFDocRef;
}
【问题讨论】:
-
人们已经在Radar 上发出了关于这个问题的声音,所以祈祷会很快被Apple 修复;这是一个 iOS9b5 错误。
-
如何在那里添加噪音?