Это опечатка во второй раз, когда вы присваиваете p.y
? Не похоже, что вы определили info
до 2 строк позже ...
Кроме того, не будет ли проще использовать NSMakePoint () и NSMakeSize () , передавая int, вместо того, чтобы создавать их вручную и использовать static_cast<float>
? Это похоже на очень C ++ подход ...
Например, что-то подобное может работать?
NSImage *image = [[NSImage alloc] initWithContentsOfFile:spoolFile];
if ([image isValid]) {
NSPrintInfo *info = [NSPrintInfo sharedPrintInfo];
[info setHorizontalPagination:NSClipPagination];
[info setVerticalPagination:NSClipPagination];
[info setHorizontallyCentered:NO];
[info setVerticallyCentered:NO];
NSImageView *view = [[NSImageView alloc] init];
[view setImage:image];
[view setImageScaling:NSScaleProportionally];
[view setBoundsOrigin:NSMakePoint(boundsX, boundsY)];
[view setBoundsSize:NSMakeSize(boundsWidth, boundsHeight)];
[view translateOriginToPoint:NSMakePoint(boundsX, [info paperSize].height -
boundsHeight - boundsY)];
NSPrintOperation *printOp = [NSPrintOperation printOperationWithView:view printInfo:info];
[printOp setShowsPrintPanel:NO];
[printOp runOperation];
}