On Jun 30, 2008, at 1:19 PM, Keith Blount wrote:

I am creating a view for printing index cards that basically takes an array of attributed strings and prints each one on a 5 x 3 card. However, if an attributed string is too long for one card, I want to wrap it across two cards or more (however many it takes). This is where my brain-deadness comes in. What's the best way of doing this? That is, what is the best way of seeing how many NSRects of a given size it takes to fit one attributed string, and the range of characters for each rect? The only thing that has come to mind is using an NSLayoutManager with multiple text containers, creating a new text container each time the layout manager finishes layout out a text container if layout is not complete (i.e. using the same method you would use for a multiple page view, a la TextEdit). I suppose I could use one text view, set at 5 x 3 inches, for the drawing, swapping in and out the text containers as necessary... But this seems a heavy-handed approach for a view that is only for printing and that will never be used for editing. Is there a simpler method, something blindingly obvious that I'm overlooking?

Using multiple text containers would be the standard way of doing this. It might also be possible to lay out your text in a single very long, 5" wide container, and go through it line by line figuring out how many lines would fit in each container, but that could end up being more work than just using multiple containers; the two techniques also might differ if there's a possibility of hard page breaks.

Douglas Davidson

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to