4
我需要用圖像陣列生成PDF文件文件我已經嘗試了這麼多類型的代碼,但我沒有得到解決方案,任何機構都可以幫助我。如何在ios中生成帶有圖像數組的單頁pdf文件?
我試過下面的代碼。
- (void)createPDFWithImagesArray:(NSMutableArray *)array andFileName:(NSString *)fileName
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *PDFPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.pdf",fileName]];
UIGraphicsBeginPDFContextToFile(PDFPath, CGRectZero, nil);
for (UIImage *image in array)
{
// Mark the beginning of a new page.
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, image.size.width, image.size.height), nil);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
}
UIGraphicsEndPDFContext();
}
但它對我沒有幫助。