• 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: Printing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing


  • Subject: Re: Printing
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 13 Oct 2006 10:13:24 +0200


On 12 Oct 2006, at 23:12, email@hidden wrote:

On 12 Oct 2006, at 20:58, Gerriet M. Denkmann wrote:

I want to print programatically. So I do [NSPrintOperation setShowsPrintPanel: NO].
But how do I tell the NSPrintOperation about the destination (fax, printer, file, etc.)? It seems always to print to the default printer, which is not what I want.

This is what I do do print something without displaying the Print panel:


- (void)markPageViewsDirtyForPrinting
{
    NSEnumerator *viewEnum;
    NSView *subView;

// Force the subviews to redisplay for printing
viewEnum = [[[scrollView documentView] subviews] objectEnumerator];
while ((subView = [viewEnum nextObject]))
[subView setNeedsDisplay: YES];
[[scrollView documentView] setNeedsDisplay: YES];
}


- (BOOL)writeToFile:(NSString *)aPath
{
    BOOL success = YES;
    NSPrintInfo *tempPrintInfo;
    NSPrintOperation *op;

tempPrintInfo = [[[self printInfo] copyWithZone: [self zone]] autorelease];
[tempPrintInfo setJobDisposition: NSPrintSaveJob];
[[tempPrintInfo dictionary] setObject: aPath
forKey: NSPrintSavePath];
[[tempPrintInfo dictionary] setObject: [NSNumber numberWithBool: YES]
forKey: NSPrintAllPages];
op = [NSPrintOperation printOperationWithView: [scrollView documentView]
printInfo: tempPrintInfo];
[op setShowPanels: NO];
[self markPageViewsDirtyForPrinting];
success = [op runOperation];


    [self setDocumentEdited: NO];

    return success;
}

Annard

Many thanks for this! I did spend hours looking in the wrong direction.

Two follow-up questions:

1. is there a way to print to an NSData? (Yes, one can print to some temp file, then read this into an NSData - but this looks rather inefficient).

2. The documentation for setJobDisposition: says: "NSPrintFaxJob is deprecated". So: what to use instead? And - if I decide to use a deprecated function - how to set the fax number?

Kind regards

Gerriet.

_______________________________________________
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


References: 
 >Printing (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Printing (From: email@hidden)

  • Prev by Date: NSTableView editing error with TAB key ...
  • Next by Date: Re: .rsrc how to
  • Previous by thread: Re: Printing
  • Next by thread: Sheets questions
  • Index(es):
    • Date
    • Thread