Generate RTF, PDF and MS XML output files - objective-c

Does anyone have any suggestions for generating RTF, PDF and MS XML reports from XCODE ?
I was thinking of creating some Objective-C classes to help do this but no doubt some may already exist.

To answer my own question...
Subclass NSDocument and generate formatted text using NSAttributedString, NSTextBlock, NSParagraphsStyle and so on...
Add the attributedString to the NSDocuments textStorage.
Add some methods to NSDocument to provide the list of supported output formats available from NSAttributedString to the Save As dialog.
It's not simple but works OK and can be used to generate formatted documents.
Things I can't figure out how to do are the following:
Make use of RTF \stylesheets so that MS Word picks up the styles used
by the different programs.
Creating new Sections, Chapters and Pages (e.g. RTF tag \page)
Creating Headers and Footers.
If anyone knows whether any of these are supported by the Apple text system please let me know. I can do this with custom RTF generator but would prefer to stick to standard API's if they exist.
Thanks

Related

How to generate PDF file using X++?

Can I create simple pdf file in x++? In this pdf I would like to have for example select from one table or simple static text.
MorphX reports can be saved to PDF by using the proper print settings beforehand.
SSRS reports can do this also using similar tricks.
Another way is to generate RTF, then let Word do the PDF creation. Silly, but maybe the PDF is smaller or better looking.
It is possible, but not simple, to generate PDF directly by using third party .Net components.
Some weeks ago, I used the Evo HTML to PDF library http://www.evopdf.com/ to convert simple HTML templates to PDF and it worked great. It can convert plain text as well, so maybe it could be useful for you.
Natively, AX hasn't anything to create PDF files.

Get text from a pdf in NSString

I am trying to make an iOS app which would extract plain text from a pdf file and display it in a UITextView. Its simply not a pdf reader to view a pdf file but i would later wish to perform certain operations on that text.
I have already googled a lot but still not able to get an exact solution.
i already tried using https://github.com/zachron/pdfiphone
but the files are using ARMV6 architecture which seems obsolete with xcode 4.5
And if anyone can suggest some exact and non-confusing code using Quartz-2d framework of iOS then it would be great.
Here is An Sample code to Extract text from PDF Hope this Might Help You.
https://github.com/zachron/pdfiphone
This is a library to get the text out of a PDF for the iPhone.
Another Demo is there Which uses OCR technology find the link below
https://github.com/nolanbrown/Tesseract-iPhone-Demo
Also Check this page of the Quartz 2D Programming Guide, it covers everything you need to open and parse a PDF file in iOS. Note that it is not a simple task, since there's no method to extract the full text in one line. You have to work with the data as an input stream, using a CGPDFScanner
Two Other Libraries
https://github.com/KurtCode/PDFKitten/
https://github.com/mobfarm/FastPdfKit
This question comes up all the time. It is VERY hard to extract text from PDF in general. The PDF specification is not designed with text extraction in mind. There are many libraries that try to do the job, essentially by reconstructing the text from the geometric placement of the individual glyphs. These libraries have varying degrees of success, but will all fail on certain PDF documents. In fact, some PDF documents have Glyphs but no way to associate the glyph with a character. For these documents it is simply not possible to extract text, short of using some kind of OCR approach.
PDF is designed as a read-only format that is portable in the sense that a PDF document will be rendered identically on any platform. That is what it is best at, and what it should be used for.
If text is to be edited, do not use PDF.
Here (Extracting text from pdf using objective-c), I found an answer to your question and it works. But not so fine as i need it :(
it can extract only ascii
it return me only one paragraph
Good luck.

Where does Preview store PDF annotations on OS X Lion?

I'm working on a tool in Python to extract highlighted passages from PDF files. I regularly highlight PDFs in Preview on OS X Lion but haven't found a good tool to extract these passages. Other apps exist that do allow you to highlight and export such as Skim but I figure there has to be a way to extract the ones I add in Preview.
I figured that the highlights would be stored in the HFS+ extended attributes for the PDF file but after looking at them using xattr it seems that they're stored elsewhere. I also looked at PDFKit but I only saw how to create annotations rather than locate them.
If someone could tell me where to find the highlights/annotations or point me at some documentation that explains this I would really appreciate it.
When using PDFKit you can get annotation from any PDFPage instance.
[myPDFPage annotations] will return an array of annotations for that particular page.
See the docs for more info.
Technically speaking, highlighting parts of a PDF is adding an annotation to the file. These annotations are PDF objects defined in the PDF specification. They are stored inside the PDF file itself, i.e. they do modify the original file! That's why you'll not find a trace of the highlights in the HFS+ extended attributes...
So the answer to the question of your title line is: Preview stores the highlights inside the PDF file as fully compliant PDF objects.
The answer to your real question implied in your text ('I want to extract the highlighted passages') was well answered by sosborn.

Show Excel and Word documents in iOS

I know that it's possible to read excel and word (modern)file in xml format, but i would like to know if exists a library useful only to present file content in a view... i don't need edit or manipulate files, i need to create a simple viewer.
I searched here for Excel/Word iOS viewer and library but i found nothing useful.
What do you suggest ? Is it possible create a views for these kind of file ?
You can use QuickLook framework for generating previews for documents, that can be handled by system (like iWorks or MS Office). See more information about this at http://developer.apple.com/library/ios/#DOCUMENTATION/QuickLook/Reference/QuickLookFrameworkReference_iPhoneOS/_index.html

How to create and save a .rtf, .doc, .docx in Objective-C for iOS

I am looking to create and save either a rtf, doc or docx file on an iPad (iOS).
The scenario is that we'd like to assist a user in creating content on their iPad and then let them email this as an editable document cross-platform (OS X, WIN).
I am open to other solutions besides the rtf, doc or docx file format.
Thanks,
James
RTF is going to be the easiest, because it's a plain text format. It's kind of like HTML, but without closing tags. Here is a class for writing an RTF, but it requires a lot of dependencies from elsewhere in the framework.
DOCX would be rather difficult. It's actually a zip file, containing a few XML files. You can examine the format yourself by changing the .docx extension to .zip and unzipping it. But even though XML is a fairly easy to write format, the way the text attributes are organized is still rather complicated. Also, I recall that it has to be zipped in a very specific way to be read properly.
As for DOC, it will be very difficult because it's such a complex format. You could look into some open source projects, like Abiword or Word2x. Be careful using their code because the licenses may not agree with the App Store rules.
I've seen doc & docx readers for iPhone (App store entry linked here), but I don't know of any open source frameworks you can make use of.
RTF format should be pretty simple to write, if you're up to the challenge. There is no built in framework support for it (here's a related question, b.t.w.).
Maybe you could write out something in a regular TEXT format and e-mail that?
Docmosis has a cloud service that you can reach from iOS. You can ask it to render a doc in various formats (doc, rtf, pdf, odt etc) and email it off or stream it back - though you have to be connected. Previewing DOC on iOS is possible but a little flaky. One option is to stream PDF back for display on iOS and email editable document (which can be done in one call).