IPhone DevelopmentApplication in progressPDFCase implementation is the content to be introduced in this article, mainly to learn about iPhone DevelopmentPDFThe content of the article is not much, mainly based on code. Let's take a look at the details.
- # Import <UIKit/UIKit. h>
- @ Class initialize testviewcontroller;
- @ Interface preview view: UIView {
- // This class encapsulates all the information drawn in PDF.
- Cgw.documentref pdf;
- // Retrieve a page from document
- CGPDFPageRef page;
- // Total number of pages
- Int totalPages;
- // Current page
- Int currentPage;
- Using testviewcontroller * using test;
- }
- @ Property (nonatomic, retain) IBOutlet implements testviewcontroller * implements test;
- // The initialization class of the current view. In this method, a cgw.docuemntref object is created, and the name and size of the required page of a PDF file are passed,
- -(Id) initWithFrame :( CGRect) frame andFileName :( NSString *) fileName;
- // Create a PDF object. This method is called in the initialization method.
- -(Cg1_documentref) createPDFFromExistFile :( NSString *) aFilePath;
-
- -(Void) reloadView;
- /*
- Jump between pages
- */
- -(Void) goUpPage;
- -(Void) goDownPage;
- @ End
- //
- // Lateral view. m
- // Define viewtest
- //
- // Created by Evan Lynn on 10-6-20.
- // Copyright 2010 restore Age. All rights reserved.
- //
-
- # Import "lateral view. h"
-
- // # Import "Export testviewcontroller. h"
- @ Implementation lateral view
- @ Synthesize upload test;
- -(Id) initWithFrame :( CGRect) frame andFileName :( NSString *) fileName {
- If (self = [super initWithFrame: frame]) {
- NSString * dataPathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: fileName];
- Pdf = [self createPDFFromExistFile: dataPathFromApp];
- Self. backgroundColor = [UIColor clearColor];
- }
- Return self;
- }
- -(Cg1_documentref) createPDFFromExistFile :( NSString *) aFilePath {
- CFStringRef path;
- CFURLRef url;
- Cgw.documentref document;
- Path = CFStringCreateWithCString (NULL, [aFilePath UTF8String], kCFStringEncodingUTF8 );
- Url = CFURLCreateWithFileSystemPath (NULL, path, kCFURLPOSIXPathStyle, NO );
- CFRelease (path );
- Document = cgw.documentcreatewithurl (url );
- CFRelease (url );
- TotalPages = cgw.documentgetnumberofpages (document );
- CurrentPage = 1;
- If (totalPages = 0 ){
- Return NULL;
- }
- Return document;
- }
- -(Void) drawRect :( CGRect) rect {
- // Obtain the drawing Context
- CGContextRef context = UIGraphicsGetCurrentContext ();
- // Get a PDF page
- Page = cgw.documentgetpage (pdf, currentPage );
- /* Perform Coordinate Transformation to move 100 units to the right, and move down the current view height,
- This is because the coordinate system for Quartz drawing starts from the lower left corner, but the iphone view starts from the upper left corner.
- */
- CGContextTranslateCTM (context, 100.0, self. bounds. size. height );
- // Transform the Coordinate System
- CGContextScaleCTM (context, 1.0,-1 );
- CGContextDrawPDFPage (context, page );
- }
- -(Void) dealloc {
- [Super dealloc];
- }
- -(Void) reloadView {
- [Self setNeedsDisplay];
- }
- -(Void) goUpPage {
- If (currentPage <2)
- Return;
- -- CurrentPage;
- [Self reloadView];
- }
- -(Void) goDownPage {
- If (currentPage> = totalPages)
- Return;
- ++ CurrentPage;
- [Self reloadView];
- }
- @ End
Summary:IPhone DevelopmentApplication in progressPDFThe implementation of the case is complete. I hope this article will help you!