我想使用ASIHttpRequest下载pdf文件。 使用的代码是
NSURL *requestUrl = [NSURL URLWithString:[urlPath objectForKey:@"url"]];
//Downloading Image
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestUrl];
NSLog(@"request.url %@", request.url);
//get the root directory:
BOOL directoryExists = [Global checkWhetherLibraryDirExists];
if(!directoryExists)
{
[[NSFileManager defaultManager] createDirectoryAtPath:[Global getLibraryDirRootPath]
withIntermediateDirectories:NO
attributes:NO
error:nil];
}
[Global DirectoryInCacheWithName:[urlPath objectForKey:@"directory"]];
NSArray *imgname = [[urlPath objectForKey:@"url"] componentsSeparatedByString:@"/"];
NSString *downLoadPath = [[Global getLibraryDirRootPath] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",[imgname objectAtIndex:[imgname count]-1]]];
[request setDownloadDestinationPath:downLoadPath];
// This file has part of the download in it already
[request setTemporaryFileDownloadPath:[NSString stringWithFormat:@"%@.download", downLoadPath]];
[request setDelegate:self];
[request setTimeOutSeconds:60.0];
if([urlPath objectForKey:@"progressView"])
[request setDownloadProgressDelegate:[urlPath objectForKey:@"progressView"]];
[request setShowAccurateProgress:YES];
[request setRequestMethod:@"GET"];
[request setShouldContinueWhenAppEntersBackground:YES];
[request startSynchronous];
我的问题是pdf文件已下载,但在webview中打开时,会出现pdf标记丢失的错误。
“找不到PDF标题:找不到'%PDF'。”