How to read pdf file from document directory in iPhone?

后端 未结 2 1946
余生分开走
余生分开走 2021-02-06 17:00

Currently i am working in iPhone application, i have an pdf file in resource folder (Local pdf file) then i read that pdf file (paper.pdf) successfully, below i have mentioned r

2条回答
  •  广开言路
    2021-02-06 17:21

    Try to use this:

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"myPDF11.pdf"];
    
    NSURL *pdfUrl = [NSURL fileURLWithPath:filePath];
    pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
    CFRelease(pdfURL);
    

    From NSURL reference:

    The NSURL class is toll-free bridged with its Core Foundation counterpart, CFURLRef. For more information on toll-free bridging, see “Toll-Free Bridging”.

提交回复
热议问题