• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: simple printing question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple printing question


  • Subject: Re: simple printing question
  • From: Peter Borg <email@hidden>
  • Date: Sat, 26 Jun 2004 09:17:15 +0200

Hi!

insertText in a NSView (or rather what it inherits from NSResponder) doesn't really do much but leaves it to the subclasses of NSView (like NSTextView) to implement it, as one can see in the documentation: "Overridden by subclasses to insert aString at the insertion point or selection, deleting the selection if there is one. NSResponders implementation simply passes this message to the next responder, or beeps if there is no next responder."

So try your code with a NSTextView instead (and try perhaps setString: instead of insertText:) which would leave you with code like this:

NSTextView *textView = [[NSTextView alloc] init];
[textView setString:[transToPrint descriptionSummary]];
op = [NSPrintOperation printOperationWithView:textView];

And remember to include a [textView release] at the end otherwise it will leak.

Regards,

Peter

On 26 jun 2004, at 02.13, Andrew Kinnie wrote:

Greetings,

I am trying to print to a receipt printer in my app I'm developing.
Basically, I am just trying to send the printer some text and have it
print without dropping the print panel. I read the apple docs, and
came up with this method from my controller method:

- (void)printReceipt:(Transaction *)transToPrint
{
NSPrintOperation *op;
NSView *view = [[NSView alloc] init];
[view insertText:[transToPrint descriptionSummary]];

op = [NSPrintOperation printOperationWithView:view];

[op setShowPanels:NO];
[op runOperation];
}

I run the app, run the method which calls this method, and I get a
dialog "No pages in the document were selected to print." The same
descriptionSummary method has it's text sent to an NSTextView, and the
text displays, so I know there is text in the document. I have not
implemented printing before, so any help would be greatly appreciated.

This is not a document based application. I'm running XCode and 10.3.4

Andrew
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >simple printing question (From: Andrew Kinnie <email@hidden>)

  • Prev by Date: URL formatting in NSAttributedString
  • Next by Date: Re: URL formatting in NSAttributedString
  • Previous by thread: simple printing question
  • Next by thread: Re: simple printing question
  • Index(es):
    • Date
    • Thread