开发者

Scaling custom pagination in a document-based Cocoa application

I am implementing printing in my document-based Cocoa application, and I'm wondering if anyone can help me out with this task.

I have to use a custom pagination scheme because the main view works in ways that normal pagination methods would not support. This works, h开发者_Go百科owever my view ends up being too big for the paper size most of the time. Tiling the view across multiple pages is not acceptable for my app, I would like to have my custom pagination work in the same way the NSFitPagination method works; if the view is too big for the page, it will resize the view by scaling it.

I thought I could do this by simply overriding the drawRect: method of my view and applying a transform to the current graphics context before it is drawn. However, it appears that printing mechanism calls the drawRect: method independently for each individual subview of a view that's being drawn, so applying a scale to the drawRect: of the superview doesn't work.

Any thoughts?


I solved this by instead of adding my view as a subview of the view to be printed, I overrode the drawRect method of the view being printed and manually set up a transformation and scaling and called drawRect on the view to print as a subview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜