• 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
Help needed with printing NSTextView contents...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed with printing NSTextView contents...


  • Subject: Help needed with printing NSTextView contents...
  • From: Darren Ford <email@hidden>
  • Date: Thu, 7 Oct 2004 20:57:39 +1000

Hi all,

I have written an application that uses the NSTextView to view RTF data. I'm trying to add printing support but have been confused with how (correctly) to set up the NSTextView to correctly print on a page.

Currently the application will print from the NSTextView, however I'm confused about how I need to set the frame of the NSTextView to print within the bounds of the page. The printing I'm doing is very simple (just print the NSTextView contents over the entire page). What I'm finding is that often the right hand side of the NSTextView contents is clipped (against what appears to be the edge of the printing area set in the page setup dialog).

In my code I tweaked the frame width to get the textview printing across the page with no clipping (as you can see in the following code with the '- 160', but this seems to me to be a hack that will fail when someone uses a custom page size.

What should I be doing here to get the correct page settings for printing?

Cheers and thanks -- Darren.

--------------------------

- (void)printDocument:(id)sender
{
NSPrintInfo *myPrintInfo = [self printInfo];

NSRect pos;
pos.origin = NSMakePoint(0,0);
pos.size.width = [myPrintInfo paperSize].width - 160;

NSTextView *PrintView = [[NSTextView alloc] initWithFrame:pos];

// Write stuff as RTF into the NSTextView
... do stuff ...

NSPrintOperation *op = [NSPrintOperation
printOperationWithView:PrintView
printInfo:myPrintInfo];

[op runOperationModalForWindow:myWindow
delegate:self
didRunSelector:
@selector(printOperationDidRun:success:contextInfo:)
contextInfo:NULL];

}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Prev by Date: Re: Crypt/Decrypt NSData
  • Next by Date: transparent NSTextView
  • Previous by thread: Re: Crypt/Decrypt NSData
  • Next by thread: transparent NSTextView
  • Index(es):
    • Date
    • Thread