0
나는 pdf 파일이 포함 된 도서관 앱을 만들었습니다. pdf를 읽기 위해 fastpdfkit을 사용했습니다.iOS에서 PDF 문서의 현재 페이지를 이메일로 보내는 방법
하지만 pdf 파일 한 페이지 만 전송할 수있는 해결책은 없습니다.
전체 문서가 아닌 pdf 파일의 현재 페이지를 이메일로 보낼 수 있습니까?.
나는 pdf 파일이 포함 된 도서관 앱을 만들었습니다. pdf를 읽기 위해 fastpdfkit을 사용했습니다.iOS에서 PDF 문서의 현재 페이지를 이메일로 보내는 방법
하지만 pdf 파일 한 페이지 만 전송할 수있는 해결책은 없습니다.
전체 문서가 아닌 pdf 파일의 현재 페이지를 이메일로 보낼 수 있습니까?.
당신이 한 페이지에 이미지가이
UIImage *currentPage = [UIImage drawCurrentView:currentPageNum];
이있는 drawCurrentView 사용할 수 원하는 경우 :
+(UIImage*)drawCurrentView:(NSUInteger)currentPageNum
{
NSString *filePath = //Your PDF Path
CGSize resultImageSize = CGSizeMake(320, 480);//For iPhone
CFStringRef pathRef = CFStringCreateWithCString (NULL, [filePath UTF8String],
kCFStringEncodingUTF8);
CFURLRef pdfURL = CFURLCreateWithFileSystemPath (NULL, pathRef,
kCFURLPOSIXPathStyle, 0);
CFRelease(pathRef);
CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL(pdfURL);
CFRelease(pdfURL);
CGPDFPageRef myPageRef = CGPDFDocumentGetPage(pdf,currentPageNum);
// get the rect of our page
CGRect pageRect = CGPDFPageGetBoxRect(myPageRef, kCGPDFCropBox);
// create a new context for resulting image of my desidered size
UIGraphicsBeginImageContext(resultImageSize);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextScaleCTM(ctx, 1, -1);
// translate so the origin is offset by exactly the rect origin
CGContextTranslateCTM(ctx, 0, -resultImageSize.height);
CGContextScaleCTM(ctx, resultImageSize.width /pageRect.size.width,resultImageSize.height/ pageRect.size.height);
// now draw the document
CGContextDrawPDFPage(ctx, myPageRef);
CGContextRestoreGState(ctx);
// generate image
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGPDFDocumentRelease(pdf);
return resultingImage;
}
drawCurrentView 무엇입니까? UIImage에 대한 방법은 없습니다. – fulberto100
오, 미안 해요 @ fulberto100 전 모든 코드를 통과하지 못했습니다 .. 내 편집을 확인하십시오. –