gpt4 book ai didi

cocoa - MacOS/appkit NSPrint 逻辑用于打印长而复杂的报告

转载 作者:行者123 更新时间:2023-12-03 18:07:35 25 4
gpt4 key购买 nike

我们有一个包含许多报告的应用程序,其中一些报告具有复杂的打印循环。

过去(IE PowerPlant、Carbon、Core Printing)我们用来创建具有某种 BeginPage()/EndPage() 对的打印循环。通常,这些对被嵌入到报告打印循环逻辑中。

最终的结果是,许多报告在打印之前没有分页,而是在打印时才分页。这些报告迭代数千个对象并尽可能多地填充页面,然后调用 EndPage(),然后通过调用 BeginPage() 继续处理下一页,同时保持内部的复杂“状态”。进度打印报告。

由于大多数核心打印已被弃用,看来按照 NSPrint 的逻辑,打印报告驱动分页的方法是不可能的。 NSPrintOperation 非常希望能够请求自定义 NSView 的 drawRect 来绘制整页,并且自定义 NSView 最好能够从任何页面开始。这是否意味着每份报告都必须预先分页?

似乎有一种不同的方法是“自动”分页的一部分:

 - (void)adjustPageHeightNew:(CGFloat *)newBottom top:(CGFloat)oldTop bottom:(CGFloat)oldBottom limit:(CGFloat)bottomLimit;

如果我正确阅读文档,假设我有一份 10 页的报告,我需要在其中找到合适的位置进行划分。看起来我可以将该报告视为一个长 View ,然后在我的绘制矩形中调用上述方法,导致我正在绘制的页面变得更短,从而将 Material 推到下一页。 p>

该文档没有提供有关此类调整如何在数十(或数百)个页面上传播的详细信息。

除了上述被动方法之外,还有其他方法可以通过报告生成代码驱动打印和分页吗?

最佳答案

If I'm reading the documentation correctly, say I had a 10-page report where I needed to find suitable places to divide. It LOOKS like I can treat that report as one long view,

是的,

 - (void)adjustPageHeightNew:(CGFloat *)newBottom top:(CGFloat)oldTop bottom:(CGFloat)oldBottom limit:(CGFloat)bottomLimit;

then call the above method while I’m in my drawRect

不,文档说:

Overridden by subclasses to adjust page height during automatic pagination. This method is invoked by print:. The view can raise the bottom edge and return the new value in newBottom, allowing it to prevent items such as lines of text from being divided across pages.

 

The documentation doesn't give much detail about how such adjustments would propagate across dozens (or hundreds) of pages.

我假设以下页面向上移动。

Are there any other methods to drive the printing and pagination from report-generation code, rather than the passive approaches described above?

是的,覆盖

- (BOOL)knowsPageRange:(NSRangePointer)range;

- (NSRect)rectForPage:(NSInteger)page;

这要求报告预先分页。

参见Selecting the Page Bounds for Content That Exceed a Single Page

Printing Programming Guide for Mac .

关于cocoa - MacOS/appkit NSPrint 逻辑用于打印长而复杂的报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61262590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com