0

Friends, I am trying to create a *.PDF file using Core Text framework in my iOS app using cocos2d. I was referring this tutorial.

I was able to put text,lines,table using lines, UIImage, etc. But when I searched for a way to add an UIView (with some attributes like, border color, background colr, corner radius, etc) to my Image, nothing helpd me.

So my question is: How can I draw an UIVIew (with some attributes like, border color, background colr, corner radius, etc) to my existing .pdf file?

Note: I don't want to add the UIView from any screenshot. I am trying to directly draw an UIVIew (or somewhat like a rounded cornered rectangle) to my pdf. I may want custome sizes. So, using a picture doesn't feels like a proper solution.

This is what I am trying to achieve:

enter image description here

Thanks in advance.

Thampuran
  • 660
  • 5
  • 21
  • 1
    "I am doing a PDF" - what's that supposed to mean? Are you referring to Adobe's Portable Document Format, or some other, lesser-known abbreviation? Also would be good if you could show some code what you've have or tried so far. – LearnCocos2D May 10 '14 at 14:15
  • Yes, it is a .pdf file creation using Core Text framework. I've already tagged that pdf. So, why are you asking? :O. Can you help me pls? – Thampuran May 10 '14 at 16:27
  • So you are looking for a way to take a screenshot (UIImage) of an existing view so that you can add it to the PDF, is that correct? Then perhaps this helps: http://stackoverflow.com/questions/2214957/how-do-i-take-a-screen-shot-of-a-uiview – LearnCocos2D May 10 '14 at 17:27
  • No, no no. Just want to add an UIVIew programmatically during the creation of .pdf file. Not from screen. Just like adding a text, I need to add an UIVIew/round cornered rectangle(not image) on a particular part of the .pdf file. Can you help me? – Thampuran May 10 '14 at 17:55
  • You want the UIView inside the PDF, right? Then you'll have to turn it into an image. Otherwise add it to one of the views or window if you want it to be interactive, but it won't become part of the PDF. – LearnCocos2D May 10 '14 at 18:14
  • First of all, yes, I want to draw an UIVIew inside my .pdf file while creating it with all other elements like text, line image, etc(I've already edited the question for more clarity). And I don't want to show that UIView on screen. Its why I am saying that, I don't want to add a view from screenshot. Are you also preferring me the same method? ie., taking screenshot of UIView? I may need several shapes like that. So u prefer create a UIView on screen for each, taking screen shot for that? Sorry, I don't feel it as a good suggestion. Any other method? – Thampuran May 10 '14 at 18:51
  • And what do you mean by 'it won't become part of the PDF'? – Thampuran May 10 '14 at 18:53
  • if it's not a custom drawn uiview you'll have to present it on screen and grab a screenshot. Can't you just provide a screenshot of the uiview with your app bundle? Alternative you'd have to create something that closely resembles the uiview using regular draw methods. – LearnCocos2D May 10 '14 at 20:38
  • Thanks for your replies. But in my app, I can't show the content/UIView in the UI(its forbidden). It is why I am saying that: I can't take a screen shot. I've added the type of UI that I need. And of course, as you said, I would like to draw something closely related to the UIView. You mean I can acheive that via drawing lines, beizer combination??? But there are lots of views. So what will I do? :( Isn't there any method to draw an UIVIew directly to the pdf? :( – Thampuran May 10 '14 at 22:21
  • what are you actually trying to accomplish with this, ie what is the reason you create a pdf, what's its use/purpose, why should there be a (dynamically generated) uiview in it? Who forbids showing the view, and why? Perhaps you will be better off creating a HTML/webview instead of pdf? – LearnCocos2D May 10 '14 at 22:58
  • As per my client's suggestion, I have to generate an activity report of prescribed format for printing and sending via mail, from the app itself. It is why I decided to create the .pdf file. The UI is in form of an UITable view, and the generated report should be as in the form shown in figure(with the question). At the time when user click print/mail action, the .pdf is created in background. It is why I am saying that the app restricts the user to view the pdf directly from the app. I know that HTML would be easier, but .pdf is prescribed for the app, as it is a standard form for reports. – Thampuran May 11 '14 at 09:58
  • @LearnCocos2D: So, can I achieve what I really need? Or do I need drop the current method and go for saving the dynamic data as .html? :( But html page is entirely different from a pdf right? It has single page, while a pdf has suitable unique sized pages as customized. So, what should I do? – Thampuran May 12 '14 at 06:11
  • maybe this helps: http://stackoverflow.com/questions/9041046/how-can-i-make-a-pdf-document-containing-a-table-of-data-on-iphone and http://stackoverflow.com/questions/5742616/generate-table-in-pdf – LearnCocos2D May 12 '14 at 07:02

0 Answers0