Printing doc file using cocoa - cocoa

Is it possible to print a doc file using cocoa application?
If possible please give some suggestions.
I printed pdf and image files.. But i didn't get any solution for doc files.
Thanks in advance,
Ramesh.P

The Word Document format is understood by NSAttributedString. It's displayed by NSTextView. The question you're really asking is "how do I print the contents of an attributed string," which reduces to "how do I print the contents of an NSTextView" at its simplest.
Even if you're not displaying the text view to the user, you'll still need an off-screen one with the desired settings to print it easily.

Related

ZPL multiple lines without wordwrap

I am trying to create a block in which a variable length of txt can be printed on a label, depending on the length of the txt, creating one or more lines of course, this is no problem using ^FB or ^TB, but here's the catch: I want to disable word-wrap. Is this somehow possible?
^FT20,130^FB550,3,,^FH^FDDescription: $_3000DE$^FS
Unfortunately the ZPL Programming Guide doesn't mention any possibility to turn of the automatic word-wrap functionality of the ^FB or ^TB command.
So the answer to your question is a simple: No, it's not possible.
However, it does allow for the wrap to happen outside of the label which is what will work.
In my example below the 999 prints the wrapped text off the label (6x4 label):
^FO65,370^A0B,40,30^FB520,2,999^FD<Company Address1 Company Address1>^FS

macOS using html tags in nstextfield

Im wondering is there any ways to make this possible:
I have a nstextfield(or nstextview). And I also have one button, clicking on that should activate Bold mode for selected text, or the text that would written further.
First idea I had - is to use attributes for characters that would be written further, but this idea is not so good, as I would need to save that string in file later. I can save attributed string, but this gives me not proper format, what I would like to see is kind of or smth like that.
If I understand correctly your "First idea" is correct. Within your program you use NSAttributedString to add bold etc. your text. When you wish to save the text you can convert to HTML, or a number of other formats, and reading these formats and converting back to NSAttributed is also supported. A good place to start is Formatted Documents and Attributed Strings.

Making a large quiz for iOS - 100+ Questions (using a .txt file or other)

I am trying to create a quiz app for iOS with 100+ questions. However, I do not want to have to design the UI by hand putting in all the values with the storyboard. I am trying to have pull values from a .txt file and use that to input values in labels and buttons. I need help doing this! I don't know how to have the compiler repeat the action of extracting the question numbers, questions, and answers that are all packed together in this .txt file and input those in the different objects every time you launch the game.
Am I being too unspecific?
Any help is appreciated!
Read the text file into an NSString. Have the data in the text file separated by commas. Use NSString's '-componentsSeparatedByString:' method (passing #"," as argument) to split all questions into an NSArray.

PDF generation under ruby - block should not cut by page separator

My PDF consists of a number of blocks (actually, a list of quotations), they go one after another till the end of the document. If the text of a quotation
does not fit on the page, the whole quotation should start from the top of the next page, instead of being torn apart. How can I implement that on any library under ruby?
Try PrinceXML - this is a standalone executable that generates PDF out of HTML or XML. It supports a lot of special CSS properties that will even help you to control page breaks. Refer to http://www.princexml.com/doc/6.0/page-breaks/
This application is available for windows and linux. I was using it for generation of a pretty complicated PDF documents with headers and footers on every page except first one. And since you don't need to output a PDF with precise positioning of elements, it might be a perfect solution for you.
I haven't tried it, but in Prawn I would try using either the Document#text_box method or looking up the table methods and putting your text in cells with invisible borders. The documentation's unclear on how page break functionality fits in with the bounding box models, but it's worth a shot.
HTMLDoc which converts HTML to PDF has a page break facility.

Create pdf using cocoa?

There is some tutorial about how to create a pdf using cocoa? I can't find anything. I looked for it on the web and it seems that I need Quartz to do it, but there aren't practical examples.
Can you help me? Thank you in advance.
—Albé
See Cocoa Printing Architecture documentation. Basically, any printing operation creates a PDF and, in general, the best way to create PDF documents is to implement custom printing layouts.
Alternatively, NSView has printing related methods for grabbing the PDF within a rectangle.

Resources