Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- totalPages = (int)CGPDFDocumentGetNumberOfPages(PDFDocument);
- NSLog(@"total pages %i",totalPages);
- //struct CGPDFPage *page =CGPDFDocumentGetPage(PDFDocument, 1);
- CGFloat width = 600.0;
- // Get the page
- CGPDFPageRef myPageRef = CGPDFDocumentGetPage(PDFDocument, i);
- // Changed this line for the line above which is a generic line
- //CGPDFPageRef page = [self getPage:page_number];
- CGRect pageRect = CGPDFPageGetBoxRect(myPageRef, kCGPDFMediaBox);
- CGFloat pdfScale = width/pageRect.size.width;
- pageRect.size = CGSizeMake(pageRect.size.width*pdfScale, pageRect.size.height*pdfScale);
- pageRect.origin = CGPointZero;
- UIGraphicsBeginImageContext(pageRect.size);
- CGContextRef context = UIGraphicsGetCurrentContext();
- // White BG
- CGContextSetRGBFillColor(context, 1.0,1.0,1.0,1.0);
- CGContextFillRect(context,pageRect);
- CGContextSaveGState(context);
- // ***********
- // Next 3 lines makes the rotations so that the page look in the right direction
- // ***********
- CGContextTranslateCTM(context, 0.0, pageRect.size.height);
- CGContextScaleCTM(context, 1.0, -1.0);
- CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(myPageRef, kCGPDFMediaBox, pageRect, 0, true));
- CGContextDrawPDFPage(context, myPageRef);
- CGContextRestoreGState(context);
- imageView= UIGraphicsGetImageFromCurrentImageContext();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement