2012-06-15 3 views
1

주석이 달린 PDF를 이미지로 변환하고 싶습니다. pdf가 성공적으로 이미지로 변환되고 있지만 주석이 변환에 없습니다.주석이 달린 PDF를 이미지로 변환하려면 어떻게해야합니까?

NSPDFImageRep *img = [NSPDFImageRep imageRepWithContentsOfFile:PdfFilePath]; 
NSFileManager *fileManager = [NSFileManager defaultManager]; 

[img setCurrentPage:0]; 

NSImage *temp = [[NSImage alloc] init]; 
[temp addRepresentation:img]; 
NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:[temp TIFFRepresentation]]; 
NSData *finalData = [rep representationUsingType:NSJPEGFileType properties:nil]; 
NSString *pageName = [NSString stringWithFormat:@"Page1_%d.jpeg", 0]; 
NSString *imgFilePath = [NSString stringWithFormat:@"%@/%@",@"/Users/Desktop/PDFImages", pageName]; 
[fileManager createFileAtPath:imgFilePath contents:finalData attributes:nil]; 

이미지에 주석을 PDF로 저장하는 다른 방법이 있나요 :

코드인가?

답변

0

이미지 잠금 및 잠금 해제 기능을 사용하여 문제가 해결되었습니다.

 NSSize  pageBounds1; 
    pageBounds1 = [page1 boundsForBox: [_pdfView displayBox]].size; 
    NSImage *temp = [[NSImage alloc] initWithSize:pageBounds1]; 

    [temp lockFocus]; 
    [page1 drawWithBox:kPDFDisplayBoxMediaBox]; 
    [temp unlockFocus]; 

    NSBitmapImageRep *rep = [NSBitmapImageRep imageRepWithData:[temp TIFFRepresentation]]; 
    NSData *finalData = [rep representationUsingType:NSJPEGFileType properties:nil]; 
    NSString *pageName = [NSString stringWithFormat:@"Page1_%d.jpg", pageIndex]; 
    NSString *imgFilePath = [NSString stringWithFormat:@"%@/%@",pathForImages, pageName]; 
    [fileManager createFileAtPath:imgFilePath contents:finalData attributes:nil]; 
관련 문제