0
是否有可能创建一个页面,其中包含其他PDF页面从源pdf中的PDF。 我喜欢使用CGContextDrawPDFPage与指定的CGRect - 像UUImage的方法drawInRect。创建pdf页面,其中包含多个pdf页面
是否有可能创建一个页面,其中包含其他PDF页面从源pdf中的PDF。 我喜欢使用CGContextDrawPDFPage与指定的CGRect - 像UUImage的方法drawInRect。创建pdf页面,其中包含多个pdf页面
CGPDFDocumentRef PDFfile;
CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("iPhoneAppProgrammingGuide.pdf"), NULL, NULL);
PDFfile = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
CFRelease(pdfURL);
-(void)drawRect:(CGRect)rect
{
{
totalpagenumpers=CGPDFDocumentGetNumberOfPages(PDFfile);
navBar.title = [NSString stringWithFormat:@"(%d/%d)",currentpage,totalpagenumpers];
CGPDFPageRef page = CGPDFDocumentGetPage(PDFfile,currentpage);
context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context,self.bounds);
CGContextTranslateCTM(context, -1.0, [self bounds].size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFArtBox, [self bounds], 0, true));
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox),
CGContextGetClipBoundingBox(context));
CGContextConcatCTM(context, transform);
UIGraphicsBeginImageContext(CGSizeMake(self.bounds.size.width, self.bounds.size.height));
}
}
-(void)Next
{
size_t pageCount = CGPDFDocumentGetNumberOfPages(PDFfile);
if (currentpage == pageCount)
{
NSLog(@"aaaaa");
}
else
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES];
[UIView commitAnimations];
currentpage++;
[self setNeedsDisplay];
}
}
-(void)Previous
{
if (currentpage == 1||currentpage<1)
{
{
NSLog(@"11111");
}
}
else
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
// self.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[UIView commitAnimations];
currentpage--;
[self setNeedsDisplay];
}
}