2016-10-04 94 views
2

我有一个应用程序派生自Xcode可可应用程序模板,可以在El Capitan上正确打印,但在Sierra上引入了一个带有阴影框的全方位厘米边距。将边距值(在viewController的viewDidLoad中的共享实例中)更改为较大的正值会使边距变大,但将边距值减小到零仍会留下边距和阴影框。该图像是打印预览的屏幕截图。我想回到让PDF占据整个打印页面。查看File/Print的菜单显示它执行firstResponder print :.我应该尝试重写此功能吗?但是,如果下面的代码被执行不起作用,这会有什么好处呢?在macOS中更改NSPrintInfo Sierra

NSPrintInfo *PageDefaults = [NSPrintInfo sharedPrintInfo]; 
[PageDefaults setBottomMargin:0]; 
[PageDefaults setLeftMargin:0]; 
[PageDefaults setRightMargin:0]; 
[PageDefaults setTopMargin:1]; 

enter image description here

如果我增加了顶部和左侧边缘在上面的代码120,打印修改: enter image description here

,故事情节表明,我只使用一个PDF浏览控制填充整个viewController场景 enter image description here

最后,屏幕上的viewController显示它看起来应该是: enter image description here

+0

如何打印什么?也许视图类改变了。我的简单测试应用程序不打印边框。 – Willeke

+0

与其说您可能在Xcode 8中创建了该应用程序,然而我的应用程序最初是在几年前在Xcode 5或6中创建的!希望我的编辑能让问题更清楚。 – Nick

+0

该项目是在OS X 10.10和Xcode 6.4中创建的。我会尝试一个PDFView。这不是10.12中PDFView的唯一问题。 – Willeke

回答

1

-[PDFView print:] 10.10调用printWithInfo:autoRotate:pageScaling:。在10.12 -[PDFView print:]调用printOperationWithView:并打印背景。解决方案:创建PDFView的子类,覆盖print:并致电printWithInfo:autoRotate:pageScaling:

- (void)print:(id)sender { 
    [self printWithInfo:[NSPrintInfo sharedPrintInfo] autoRotate:YES pageScaling:kPDFPrintPageScaleToFit]; 
} 
+0

绝对完美!谢谢。 – Nick