Is it possible to create a page with formatted text that is stored in core data. The text would need to be displayed with paragraphs and a few images. I have already written the code to create a PDF with one line of text, but I am unsure of the pattern needed to layout the PDF in a nice document way. One of reasons is I had to write the code in C. The data that will be in the document is of course In core data. And I do not know what the best practice is for what I am trying to do.
A:
I am quite sure NSData (your c bytes) could be stored in NSManagedObject. Even if not. Why don't store only metadata in CoreData? Is much more simpler for example: info needed to render the page wanted, etc. I am not sure archiving the hole PDF in CoreData is a good approach.
nacho4d
2010-07-16 03:06:53
A:
Unless you have a particular need for PDF, the best practice is to use HTML and UIWebView. WebView is the primary formatted-text displayer for iPhone. iPhoneOS 3.2 added CoreText, which is another option if you have serious layout needs, but it generally isn't needed for simple formatted text and data.
The Text and Web Programming Guide includes a good discussion of your formatting and layout options. Generally UIWebView is still your best bet.
Rob Napier
2010-07-16 04:08:57
is it possible, once the UIWebView is styled and formatted, to create a PDF out of that View and email it to the user?
iAm
2010-07-16 12:40:37
I'm not familiar with a method on iPhone. On Mac, it's NSView -dataWithPDFInsideRect:. Trying to capture the rendered view into PDF data is likely to be frustrating. If your real goal is a PDF rather than formatted text, then you may need to build it up by hand. The layout routines you likely want are in NSString(UIStringDrawing). Search for sizeWithFont: and you'll find the page. Actually working out where each paragraph goes is your issue. If complicated, you should read up on Core Text, CTTypesetter, etc. If simple, draw it a paragraph at a time with the UIStringDrawing methods.
Rob Napier
2010-07-16 13:48:09
Rob thank u for sharing I will investigate. I am also looking into the possibility of writing HTML but need to know if I can embed cocoa messages in-between the HTML tags. I do know I can create nsstrings that have HTML tags in them, but I would really like to layout a normal HTML page.
iAm
2010-07-16 14:12:28
Generally I have addressed this by laying out the HTML in a static Resource file and substituting tags in it. For instance, I would search for %NAME% and replace it with my data.
Rob Napier
2010-07-16 16:36:48