Printing page breaks in an attributed string?
Printing page breaks in an attributed string?
- Subject: Printing page breaks in an attributed string?
- From: Joshua Scott Emmons <email@hidden>
- Date: Sun, 4 Jun 2006 16:53:42 -0500
I have a multi-page attributed string that I need to print in my
application. For the most part, this is very straight forward. I have
an NSView subclass that sets up a large NSTextView inside of it with
the proper origin and width. The text view is set to expand
vertically, so I just add my string to it, it makes itself the right
size, I set my NSView to that size, and we print. Nice and simple!
The problem is that my attributed string can contain page breaks
(that is, a characters that, when encountered, should make the very
next part of the string appear at the top of the next logical page).
NSTextView does not seem to handle page breaks automagically, so I've
been looking to make my own solution.
First I thought -[NSView adjustPageHeightNew:top:bottom:limit:] was
going to solve my problems. But because of the heightAdjustlimit, it
only lets me break pages that have the page-break character in the
bottom limit% of the page. So that won't work.
Then I thought I'd just lay out multiple NSTextViews in my view, one
for each page break, and make sure that each one's origin had a y
value that's a multiple of the page height. This works well unless
one of the pages before is long enough to be broken on to multiple
pages. If that happens, the total size of that NSTextView gets
adjusted by NSTextView's implementation of -adjustPageHeightNew:...
so that lines of text don't get cut in half. But that means one
page's view can unpredictably overlap another's if there are enough
of these adjustments.
So that leaves me with rolling my own custom pagination scheme. But
that seems a lot of work to support something as simple as page
breaks in an otherwise plain vanilla attributed string. Am I over-
thinking this and missing something obvious? Does any one know of
examples that touch on this?
Many thanks!
-Joshua Emmons
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden