小编mra*_*sch的帖子

如何在Objective C for iPad中解析PDF

我很难解析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)

pdf objective-c ipad

7
推荐指数
1
解决办法
9969
查看次数

标签 统计

ipad ×1

objective-c ×1

pdf ×1