我想从字节流(我从 wsdl 接收)创建一个 pdf,我已经在 NSArray 上插入了这个字节流,但我不知道如何编写 pdf。(这个字节流是pdf)谢谢!
//to convert NSData to pdf
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:arrayOfByte];
CFDataRef myPDFData = (__bridge_retained CFDataRef)data;
CGDataProviderRef provider = CGDataProviderCreateWithCFData(myPDFData);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithProvider(provider);
NSArray *docDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [docDirectories objectAtIndex:0];
NSString *fileName = [docDirectory stringByAppendingPathComponent:@"abcd.pdf"];
[data writeToFile:fileName atomically:NO];
但我收到:未能找到 PDF 标题:找不到“%PDF”。