0
我製作了一個包含pdf文件的圖書館應用程序。 我使用fastpdfkit閱讀pdf。如何在iOS上發送pdf文檔的當前頁面
但是沒有辦法只發送一個pdf文件的頁面。
是否可以通過電子郵件發送PDF文件的當前頁面,而不是整個文檔?
我製作了一個包含pdf文件的圖書館應用程序。 我使用fastpdfkit閱讀pdf。如何在iOS上發送pdf文檔的當前頁面
但是沒有辦法只發送一個pdf文件的頁面。
是否可以通過電子郵件發送PDF文件的當前頁面,而不是整個文檔?
,如果你想1頁圖像您可以使用此
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 2012-02-25 23:10:42
哦對不起@ fulberto100我沒有通過所有的代碼..請檢查我的編輯。 – 2012-02-25 23:27:27