问题
Hi I've been trying to achieve this with no success
I'm trying to take the following code and view it using Quartz 2D - So I could later annotate using this:
$
NSString *path = [[NSBundle mainBundle] pathForResource:@"01renalArtery" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[pdfView loadRequest:request];
[pdfView setScalesPageToFit:YES];
$
I've been through the following sample code https://developer.apple.com/library/mac/#documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html#//apple_ref/doc/uid/TP30001066-CH214-TPXREF101 kept coming back with tons of errors
And this Rendered a blank screeen Writing text to a PDF via from an NSString
Any help is very appreciated
回答1:
I was about ask for some clarification on your question if you want to edit the PDF or just view it. Your comment made things clearer.
I have very recently written basic PDF viewer with functionality to let user add images to exiting PDF. I would advise you that if you are fine with using existing libraries available for this purpose, you should certainly go for it.
Writing PDF viewer and editing PDFs is not a straightforward job in iOS. If you need to write your own code from scratch, this answer has some pointers that helped me in achieving what I needed. Also the link mentioned by @ModernCarpentry this is very good collection of all resources related to this topic.
Feel free to comment if you need any more help in this regard.
回答2:
Your code looks as if it was meant for an UIWebView, which, depending on what you would like to achieve, is all you would need. Make sure the pdfView is an UIWebView and your PDF should load just fine. No need for drawing with Quartz 2D if you just want to view the PDF.
来源:https://stackoverflow.com/questions/17126974/how-to-open-and-view-pdf-using-quartz-2d