In my work, I just want to read a downloaded PDF in iphone device
At first, I tried to use the "bundleRoot" directory, it is work in simulator but not on device. Now, I just test in simulator for Directory of Document or Cache.
How can I get a writable path on the iPhone?
After I read the above topic,
I have tried using Directory of Document or Cache.
Here is my code in finding the writable path
/******************************************************************************/
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [paths objectAtIndex:0];
BOOL isDir = NO;
NSError *error;
if (! [[NSFileManager defaultManager] fileExistsAtPath:cachePath isDirectory:&isDir] && isDir == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
}
NSString *path_to_file = [cachePath stringByAppendingPathComponent:@"testing6.pdf"];
/******************************************************************************/
I can find the downloaded file and get the size in this directory,but I cannot read the file by using the following code :
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
page = CGPDFDocumentGetPage(pdf, 1);
CGPDFPageRetain(page);
CGRect pageRect = CGPDFPageGetBoxRect(page, kCGPDFMediaBox);
The return pageRect.size.width is 0
After I print out the download and retrieve file path also are :
/Users/ITDEV/Library/Application Support/iPhone Simulator/4.3.2/Applications/806ED359-70F8-4C07-996F-6AFC959B3FC7/Library/Caches/testing6.pdf
Anyone can help me pls?