show a downloaded pdf with CGPDFDocumentRef

I have a problem and i hope someone can help me.

I download a PDF File to the 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];

that is not the whole code but i hobe you understand what I mean.

After that i will show this PDF

CGPDFDocumentRef pdf;
CFStringRef fullPathEscaped = CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)studioPath, NULL, NULL,kCFStringEncodingUTF8);

CFURLRef docUrl = CFURLCreateWithFileSystemPath (NULL, fullPathEscaped, kCFURLPOSIXPathStyle, FALSE);  
pdf = CGPDFDocumentCreateWithURL(docUrl);

but it crash always when i use the internet url instead of the studioPath to the PDF it works but i would't download the pdf more then once.

Answers


Try this one

 CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
    //file ref
    CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);

Need Your Help

CloudBees Service Level Agreement(s) and Capabilities Service

java saas high-availability cloudbees paas

I have been comparing Java PaaSes carefully and am really starting to like CloudBees. I only have one big concern with them, and that is their SLA/uptime.

Fill a DataGrid from two different sources?

c# sql datagrid

I have a DataGrid with 3 Columns. I would like to fill the first two columns from one SQL Table and the third column from a separate table. I can easily fill it from one source with a DataSet from my

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.