0

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

Community
  • 1
  • 1
Taskinul Haque
  • 724
  • 2
  • 16
  • 36
  • Depending on your needs, viewing pdfs on iOS can be quite a task. If you're comfortable using another library, [this one](https://github.com/vfr/Reader) is good. If you want to write your own, this [thread](http://stackoverflow.com/questions/3889634/fast-and-lean-pdf-viewer-for-iphone-ipad-ios-tips-and-hints) was very useful for me. – ModernCarpentry Jun 15 '13 at 19:13

2 Answers2

2

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.

Community
  • 1
  • 1
zambrey
  • 1,452
  • 13
  • 21
  • thank you for your advice, it will defenitely be helpful shortly: but what I"m looking for right now is not to generate a pdf but to view an existing pdf on screen, all your efforts are very much appreciated, thank you :) – Taskinul Haque Jun 16 '13 at 23:17
0

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.

Oskar
  • 3,625
  • 2
  • 29
  • 37
  • Thank you for your input, my code is working just fine, but I'm trying to draw it with Quartz 2d, because at the end of the day I want to be able to add text to the PDFs . . . . – Taskinul Haque Jun 15 '13 at 19:25