我很难解析PDF文件.请指导我如何做到这一点.
头文件.
//PDFViewer.h
@interface PDFViewer : UIView
{
CGPDFDocumentRef pdf;
}
-(void)drawInContext:(CGContextRef)context;
@end
Run Code Online (Sandbox Code Playgroud)
实施文件
//PDFViewer.m
@implementation PDFViewer
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
// Initialization code
if(self != nil)
{
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("WR1MayJun1S08.pdf"), NULL, NULL);
pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
}
}
return self;
}
-(void)drawInContext:(CGContextRef)context
{
// PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
// before we start drawing.
CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
// Grab the …Run Code Online (Sandbox Code Playgroud)