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