2014-04-11 66 views

回答

0

試試這個:

NSData *pdfData = [NSData dataWithContentsOfFile:pathToUrPDF];  
NSPDFImageRep *pdfImg = [NSPDFImageRep imageRepWithData:pdfData]; 
NSFileManager *fileManager = [NSFileManager defaultManager]; 
NSInteger pageCount = [pdfImg pageCount]; 
for(int i = 0 ; i < pageCount ; i++) { 
    [pdfImg setCurrentPage:i]; 
    NSImage *temp = [[NSImage alloc] init]; 
    [temp addRepresentation:pdfImg]; 
    NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:[temp TIFFRepresentation]]; 
    NSData *finalData = [rep representationUsingType:NSJPEGFileType properties:nil]; 
    NSString *pageName = [NSString stringWithFormat:@"Page_%ld.jpg", (long)[pdfImg currentPage]]; 
    [fileManager createFileAtPath:[NSString stringWithFormat:@"%@/%@", @"pathWrUWantToSave", pageName] contents:finalData attributes:nil]; 
} 
+0

親愛的香提K,你能幫我嗎? http://stackoverflow.com/questions/23626526/how-to-convert-pdf-to-nsimage-and-change-the-dpi – SuperBerry

相關問題