我在我的应用中收到了一个PDF文件:
NSURL* pdfURL = [NSURL URLWithString:urlStr];
CGPDFDocumentRef PDFDocument = CGPDFDocumentCreateWithURL((__bridge CFURLRef)pdfURL);
CGPDFPageRef PDFPage = CGPDFDocumentGetPage(PDFDocument, 1);
我知道对于图像,我们可以使用此方法将其保存在iPhone中:
[UIImagePNGRepresentation(image) writeToFile:uniquePath atomically:YES];
但有没有办法以编程方式在iPhone中编写/保存PDF文件?
答案 0 :(得分:3)
这是一个简单的方法:
NSData *myFile = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"your_url"]];
[myFile writeToFile:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"yourfilename.pdf"] atomically:YES];
答案 1 :(得分:-5)
除了UIImage之外,无法以编程方式将任何数据保存到iPad内存。