PDF Page Drawing issue with iPhone sdk
<p>I herewith a problem that i am facing while implementing PDF file in iPhone.</p>

<p>What I want is simply display PDF files. and also Giving few Facilities like Zoom-in and Zoom-Out, Next Page navigation, Previous Page Navigation etc.</p>

<p>I am very clear with Reading PDF Documents using url, i also get the number of pages and other property, But When i try to display it in View or WebView, i mean to say when i try to draw a pdf page, I am not getting page, just get simply blank View.</p>

<p>To Display page, I tried 5 different approaches, but none of them leads me to Success.  Hence i have to approach You Guys.</p>

<p>I have attached here snippet of Code with 5 different approach i used.</p>

<p>Kindly go through it and guide me!! Your Suggestions are welcomed.</p>

<p>////////////////////////////</p>

<pre><code>- (void)viewDidLoad {
    [super viewDidLoad];

 const char *file = @"Pdf_first.pdf";

 CGPDFDocumentRef myDocument;
 CGPDFPageRef page;
 CGRect mediaBox;
  CFStringRef path;
 size_t noOfPages;
    CFURLRef url;
 CGContextRef pdfContext;



//////// Code to get Path and Url for the dictionary where our PDF file currently stored. /////////

 NSFileManager *FileManager = [NSFileManager defaultManager];
 NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectory = [paths1 objectAtIndex:0];
 documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"Pdf_first.pdf"];

 path = documentsDirectory;

    url = CFURLCreateWithFileSystemPath (NULL, path,kCFURLPOSIXPathStyle, 0);
 myDocument = CGPDFDocumentCreateWithURL(url);
 myDocument = CGPDFDocumentRetain(myDocument);


 CFMutableDictionaryRef myDictionary = NULL;
 myDictionary = CFDictionaryCreateMutable(NULL, 0,&amp;kCFTypeDictionaryKeyCallBacks,&amp;kCFTypeDictionaryValueCallBacks);
 CFDictionarySetValue(myDictionary, kCGPDFContextTitle, CFSTR("My PDF File"));
 CFDictionarySetValue(myDictionary, kCGPDFContextCreator, CFSTR("My Name"));



 page = CGPDFDocumentGetPage(myDocument, 1);
 noOfPages = CGPDFDocumentGetNumberOfPages(myDocument);
 pdfContext = CGPDFContextCreateWithURL(url, NULL, myDictionary);
 CGRect pageMediaBox = CGPDFPageGetBoxRect(page, kCGPDFMediaBox); 

//////// Code to get Path and Url for the dictionary where our PDF file currently stored. /////////
</code></pre>

<p>Every Thing is fine here!! i am Getting all Values from Functions. Now Bellow i have added 5 different ways Those 
    i Follow for Displaying or Drawing a Page That i can see in iphone.</p>

<pre><code>////////////////////////// Way 1 ///////////////////////

 CGContextTranslateCTM(pdfContext, 0.0, [webView bounds].size.height);
 CGContextScaleCTM(pdfContext, 1.0, -1.0);
 CGContextConcatCTM(pdfContext, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox,[webView bounds], 0, true));
 CGContextDrawPDFPage(pdfContext, page);    
 CGContextRestoreGState(pdfContext);

 ////////////////////////// Way 1 ///////////////////////


////////////////////////// Way 2 ///////////////////////

 CGRect bounds = CGRectMake(10, 10, 300, 300);

 CGContextSaveGState(pdfContext);
 CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, bounds, 0, true);
 CGContextConcatCTM(pdfContext, pdfTransform);
 CGContextDrawPDFPage(pdfContext, page);
 CGContextRestoreGState(pdfContext);

 ////////////////////////// Way 2 ///////////////////////

///////////////////////////////////// Way 3 ////////////////////


    for(int i = 1; i &lt;= noOfPages; ++i) {

        CGPDFPageRef pdfPage =  CGPDFDocumentGetPage(myDocument, i);

        CGRect pageMediaBox = CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox); 

        CGContextBeginPage (pdfContext, &amp;pageMediaBox); 

  CGContextStrokeRect(pdfContext, CGRectMake(50, 50, 500,700)); 
  CGContextShowTextAtPoint (pdfContext, 60, 699, text, strlen(text));

  CGContextDrawPDFPage(pdfContext, pdfPage);

        CGContextEndPage (pdfContext); 

    }

  ///////////////////////////////////// Way 3 ////////////////////

 /////////////////////////////// Way 4 ////////////////////////////////

 //mediaBox = CGPDFDocumentGetMediaBox(document, 1);

 CGPDFBox mediaBox = CGPDFDocumentGetMediaBox(document, 1);

 //mediaBox = CGRectMake(10,10,300,300);
 // int rotationAngle = CGPDFDocumentGetRotationAngle(document, 1);

 int rotationAngle = 30;

 //CGContextDrawPDFDocument(UIGraphicsGetCurrentContext(), CGRectMake(25,25,250,250), document, 1);

 //CGPDFPageGetDrawingTransform(&lt;#CGPDFPageRef page#&gt;, &lt;#CGPDFBox box#&gt;, &lt;#CGRect rect#&gt;, &lt;#int rotate#&gt;, &lt;#_Bool preserveAspectRatio#&gt;)

 CGAffineTransform transform = CGPDFPageGetDrawingTransform(page, mediaBox, CGRectMake(25, 25, 250,250), rotationAngle, TRUE);


   /////////////////////////////// Way 4 ////////////////////////////////

///////////////////////// Way 5 /////////////////////////////

 CGContextTranslateCTM(pdfContext, 0.0, 320);

 CGContextScaleCTM(pdfContext, 1.0, -1.0);

 CGContextSaveGState(pdfContext);

 CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, CGRectMake(0, 0, 280, 320), 0, true);

 CGContextConcatCTM(pdfContext, pdfTransform);

 CGContextDrawPDFPage(pdfContext, page);

 CGContextRestoreGState(pdfContext);

    ///////////////////////// Way 5 /////////////////////////////
</code></pre>

<p>Among above 5 diffent way not single one lead me to Result.</p>
