i'm going to make a PDF reader and i'm trying two possible solutions:
The first one is very simple, but is slower than the second one. For the second one, i found a tutorial and i can view a pdf and i can zoom it with the two fingers movement. But at the moment i can't do 2 things :
1) View the PDF in landscape mode, maintaining the correct proportions. 2) Do a zoom in / zoom out with the double tap on the screen.
Those functions are already implemented in the UIWebView, but how said before, it's a little bit slow and it opens the entire PDF doc and not only a single page (so i need to split the file in many "one page pdf files").
Anyone can help me with some links/references/code about those kind of problems ?
With CGPDFDocumentRef
, you need to get each page with CGPDFDocumentGetPage
and then get the drawing transform with CGPDFPageGetDrawingTransform
and apply that to the CGContextRef
before you draw the page.
Putting the view with your PDF page in a UIScrollView will let you zoom in and out, if you enable zooming. You can also draw it with a zoom factor using
CGContextTranslateCTM (context, -sourceRect.origin.x * zoom, -sourceRect.origin.y * zoom);
CGContextScaleCTM (context, zoom, zoom);
But you'll still run into the issue that very complex PDF pages will be slow to render, and every time you call CGContextDrawPDFPage(context, page);
it has to render the entire page, such as when you change the zoom level. There are ways around this, such as drawing into a CATiledLayer.