printing 4"x6" cards in OSX (cocoa)
I'm trying to get 4x6 cards to print in Cocoa (story cards). I have a view where I put the data but when I print it prints in the correct orientation, only on 8x11 paper (in other words, it prints oriented correctly on letter size paper with the origin in the upper left corner -- lower left if you are holding the output in landscape mode). When a 4x5 card is fed through the printer it appears to be getting just the last bit of the printout (in other words, if the 4x6 card is superimposed over the letter paper it appears to be centered in the middle right if looking at the paper in landscape mode. The printer seems to be imaging for letter, not 4x6. It must have something to do with how I'm configuring the NSPrintInfo object...but for the life of me I can't figure it out. I've tried it on several different printers and I keep getting the same results.
Any ideas?
The code that does th开发者_如何学运维e printing looks like this:
- (IBAction)printCard:(id)sender
{
int i;
for (i=0; i<[storyCards count]; i++)
{
StoryCard * card = [storyCards objectAtIndex:i];
NSPrintInfo *printInfo = [[NSPrintInfo sharedPrintInfo] copy];
[printInfo setPaperSize:NSMakeSize(4*72, 6*72)];
[printInfo setOrientation:NSLandscapeOrientation];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setVerticalPagination:NSFitPagination];
[printInfo setLeftMargin:10.0];
[printInfo setRightMargin:10.0];
[printInfo setTopMargin:10.0];
[printInfo setBottomMargin:10.0];
StoryCardView *view = [[StoryCardView alloc] initWithFrame:[printInfo imageablePageBounds]];
[view setStoryCard:card];
NSPrintOperation *printOp = [NSPrintOperation printOperationWithView:view printInfo:printInfo];
[printOp runOperation];
[view release];
}
}
Problem had to do with using a generic postscript driver for the printer in OSX. Once I switched to a specific driver for the printer the custom paper sizes worked like a charm.
Thanks for all of the help...
--Robert
精彩评论