【问题标题】:How to print CorePlot Graph如何打印 CorePlot 图形
【发布时间】:2014-04-02 13:56:21
【问题描述】:

我正在尝试打印一个 NSView,其中包括几个 coreplot 饼图以及其他项目。但是饼图没有出现。我现在明白图层支持的视图不会打印,但我很难找到人们绕过这个并在 NSView 中打印 coreplot 图表的任何示例。最好的方法是什么?

【问题讨论】:

    标签: cocoa calayer core-plot


    【解决方案1】:

    对我来说,只要我设置了 printRect 就可以了:

    NSRect printRect = NSZeroRect;
    printRect.size.width  = (printInfo.paperSize.width - printInfo.leftMargin - printInfo.rightMargin) * printInfo.scalingFactor;
    printRect.size.height = (printInfo.paperSize.height - printInfo.topMargin - printInfo.bottomMargin) * printInfo.scalingFactor;
    
    self.hostingView.printRect = printRect;     
    op = [NSPrintOperation printOperationWithView:self.hostingView printInfo:printInfo];
    

    注意self.hostingView指的是CorePlot hostingView。

    【讨论】:

    • 谢谢,这让我朝着正确的方向前进,如果您只想绘制单个图表,这非常有用。但是,我在 NSView 中有几个图表,还有其他项目,所以我想打印所有项目,因为我在 NSView 中布置了它们。但这肯定会让我开始。
    • 只需将每个主机视图中的 printRect 属性设置为 [self view] frame]] 即可!再次感谢!
    • 其实很简单:self.hostingView.printRect = self.hostingView.bounds
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-03
    • 2013-02-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多