views:

1723

answers:

4

I'm using the quartz rendering engine to display a PDF file on the iphone using the 3.0 SDK. The result is a bit blurry compared to a PDF being shown in a UIWebView. How can I improve the quality in the UIView so that I don't need to rewrite my app to use the UIWebView. I'm using pretty much close to the example code that Apple provides.

Here is some of my sample code:

CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextSaveGState(gc);
CGContextTranslateCTM(gc, 0.0, rect.size.height);
CGContextScaleCTM(gc, 1.0, -1.0);    
CGAffineTransform m = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, rect, 0, false);
CGContextConcatCTM(gc, m);  
CGContextSetGrayFillColor(gc, 1.0, 1.0);
CGContextFillRect(gc, rect);
CGContextDrawPDFPage(gc, page);
CGContextRestoreGState(gc);

Apple's tutorial code actually results in a blurry PDF view as well. If you drop the same PDF into a UIWebView you'll see it is actually sharper. Anyone have any ideas? This one issue is holding a two year development project from launching. :(

A: 

Josh,

Don't know if you've finally resolved this, but if so, I'd love to know what you came up with. I've wrestling with the same issue for quite some time. I'm told the solution is to use a CATiledLayer, but haven't gotten that to work yet. Like you I started from Apple's sample code. I basically have a UIView subclass inside a UIScrollView and do the drawing in the drawRect:(CGRect)rect method. I've experimented with the CGContextScaleCTM call by changing the 1.0 & -1.0 arguments to the current zoom scale. That does cause the text to be redrawn sharper, but it messes up the size of the view so that dragging within the UIScrollView doesn't display the entire page.

Bob

Bob
A: 

I would love to know how you did this. I am having the same problem.

Aron

aron
A: 

Can you please send me the code on [email protected]. I have same porblme . Saved PDF is very blurr

Manoj
A: 

I am experiencing the same issue! If anyone has reached (even partially) further please share.

The I couldn't make the solution with CATiledLayer working as I think these CATiledLayers have issues with zooming...

Best Regards!

Sasho