我有一个问题,我希望有人能帮助我。
我将一个PDF文件下载到DocumentDirectory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, TRUE);
NSString *documentsDirectory = [paths objectAtIndex:0];
studioPath = [[documentsDirectory stringByAppendingPathComponent:@"test.pdf"] retain];
ASIHTTPRequest *request = [[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://testURL.com/test.pdf"]] retain];
[request setDownloadDestinationPath:studioPath];这不是全部代码,但我希望您能理解我的意思。
之后,我将显示此PDF
CGPDFDocumentRef pdf;
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)studioPath, NULL, NULL,kCFStringEncodingUTF8);
CFURLRef docUrl = CFURLCreateWithFileSystemPath (NULL, fullPathEscaped, kCFURLPOSIXPathStyle, FALSE);
pdf = CGPDFDocumentCreateWithURL(docUrl);但它总是崩溃,当我使用互联网的网址,而不是PDF的studioPath,它可以工作,但我不会下载pdf超过一次。
发布于 2012-03-12 20:44:09
试试这个
CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
//file ref
CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);https://stackoverflow.com/questions/4545681
复制相似问题