CGPDFDocumentCreateWithURL问题

时间:2010-10-08 11:34:28

标签: iphone objective-c core-graphics

  

可能重复:
  Load PDF from documents directory - iPhone

我正在尝试从我存储在文档目录(1.pdf)中的文件创建PDF。这是我的代码:

// Get Documents Directory
    NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectoryPath = [searchPaths objectAtIndex:0]; 
    NSString *tempPath = [documentsDirectoryPath stringByAppendingPathComponent:[appDelegate.issueToLoad stringByAppendingPathExtension:@"pdf"]];
    NSString *path = [tempPath stringByReplacingOccurrencesOfString:@"localhost/" withString:@""];
    NSLog(@"PATH: %@", path);
    //Display PDF
    pdf = CGPDFDocumentCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path]);
    NSLog(@"PDF: %@", pdf);

第一个NSLog生成一个指向该文件的链接:

  

/ Users / myname / Library / Application Support / iPhone Simulator / 3.2 / Applications / 9C2047A6-DDD2-418F-A329-4EE6E4647770 / Documents / 1.pdf

然而,第二个NSlog产生:

  

(NULL)

我的代码有问题吗?

由于

0 个答案:

没有答案