0

I'm trying to add a View (specifically a UIImageView) to every page of a pagenated UIWebView on iPhone/iPad. My end goal is to open a PDF and have a signature box at the bottom of every page of the (possibly multipaged) PDF. I followed this tutorial to use a UIImageView as a signature box and this tutorial to successfully open a PDF in a UIWebView.

My plan was to programmatically get each "page" of a UIWebView and add my signature box at the bottom of each page (stack the views one on top of another). Is it possible to get each page of a UIWebView? Does cocoa know where each page is or does it do some fancy math calculations to know where to put line breaks?

Ideally, there would be something like:

for(UIView *page in webView.pages){
      [self addSignatureBox:page];
 }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Tyler
  • 1
  • 1
  • UIWebView makes displaying a PDF a piece of cake, but I would suggest looking into CGPDFDocumentRef. This allows you to grab one page and display it in a View how ever you want. – NixonsBack Mar 08 '11 at 17:23
  • Cocoa is the Mac development framework; all UI* classes are specific to Cocoa Touch. – Peter Hosey Mar 08 '11 at 21:43
  • Yes, but it is also available on the iPhone. iOS developers are not limited to the UI classes. I know this because I used CGPDFDocumentRef. – NixonsBack Mar 09 '11 at 18:43

1 Answers1

0

You can get the HTML code for any page in the webview. Check out the following link.

Reading HTML content from a UIWebView

Store the HTML code for the webpages in a NSString and modify them to add your signature.

Hope this helps

Community
  • 1
  • 1
HG's
  • 818
  • 6
  • 22
  • Is there a way I can go from the HTML code to inserting cocoa objects (ie, the UIImageView)? I was thinking I would put the UIImageView over the top of the UIWebView (stack the views). Should I instead be looking at imbedding the code for the UIImgeView in the actual HTML? – Tyler Mar 08 '11 at 17:03
  • Its better to add the imageView on top of the webView. Embedding the image in the HTML will be too hectic. Adjust the size of the imageView by the imageView.frame = CGRectMake(x,y,width,height) method and add it using the [self.view addSubview:imageView]. To get the pages, get the HTML code as said in the link and load them back into the webview when required. – HG's Mar 08 '11 at 17:26
  • Would I be able to tell where the page breaks are merely from the HTML? – Tyler Mar 08 '11 at 17:49
  • You will have to search the NSString for the page break tags. There are inbuilt methods for searching a substring within a string. – HG's Mar 08 '11 at 18:08