I'm writing an application that does a lot of printing of various
types. I've gotten all of that working pretty well. One problem I
have is that all of my print jobs end up in the print queue as
"Untitled". I'd rather have them indicate something like
"OrderForm237" or "Checklist020", under program control. I have
searched through all of the NSPrintInfo and NSPrintOperation
classes for anything resembling a "print job name" property, but
haven't found anything. No luck either with extensive web searches
on non-Apple sites.
Does anybody know how to do this?
On a similar issue, if the user chooses to print to PDF, is there a
way to provide the printing dialog controls with a default name and
path for the file. I always get a default of "Untitled.pdf", and
the default folder seems to be the same as was last used to save-to-
pdf, regardless of where my document is located. Again, I'd like
to put the default name and folder under program control.
I received a quick and friendly response from John at Apple on my
questions. I quote that here so that others might be able to
discover the same thing...
For the first question, the easiest way to do this is to override
NSView's printJobTitle method.
On the second question, we don't provide a way to do this. If
it is important, you can file an Enhancement Request in Radar
requesting this.
I hope this helps.
It certainly did help. I never would have thought to look at the
NSView methods for this, but sure enough, there it is. Apparently,
the "normal" printing process assumes the NSView is part of an
NSDocument or an NSWindow. The print operation asks the NSView for a
print job name using (duh!) printJobTitle, which by default extracts
a name or title from the NSView's "parents".
In my case, I had created the NSView independent of the Document or
GUI windowing system. The user never sees my custom NSView except on
paper or in PDF. So there was no parent to get the printJobTitle
from, and I ended up with "Untitled". To solve this, I simply added
(in my custom NSView) an override version of printJobTitle that
returns an NSString that I can set to whatever I want. Viola... My
print jobs now indicate what they contain and I'm happy.
I also find that the same printJobTitle is used as the default name
when saving a print job to PDF. So if my real print jobs were named
"Checklist123-127", the default PDF file shows as
"Checklist123-127.pdf". That's two of my problems solved. The
default folder where the saved PDFs end up is still not under my
complete control, but this is still a big step toward how I want my
application to behave.
My thanks to John for his help.
Tom Coates :::/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Printing mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/printing/email@hidden