Thanks Matt, for the advice. I followed your links, and found the best way, for me at least, to print what I wanted was to create a view in IB, populate a custom view with text fields and tables, and then resize that view for printing.

For those who are working on a similar problem, I created new view controller object from -printOperationWithSettings:, and that view object in turn creates the view that I want to print. That view implements various other subviews, but I was still having problems breaking pages at appropriate points. The subviews, however, can say where they should be broken by using -adjustPageHeightNew:. In my NSTableView subclass, which was the main element in the view, I implemented that method as follows:

-(void)adjustPageHeightNew:(CGFloat *)newBottom top:(CGFloat)top bottom:(CGFloat)proposedBottom limit:(CGFloat)bottomLimit
{
        *newBottom = proposedBottom;

        NSInteger indexCount = [deduction lineCount]-1;
        for (NSInteger i = indexCount; i>0; i--)
        {
NSRect rowRect = [self frameOfCellAtColumn:[self columnWithIdentifier:@"MyColumn"] row:i];
                float bottomOfRow = rowRect.origin.y + rowRect.size.height;
                if (bottomOfRow < proposedBottom)
                {
                        *newBottom = bottomOfRow + 1.0;
                        break;
                }
        }
}

So, the for loop just goes through the table and adjusts *newBottom so that it breaks at appropriate places. There is probably some more efficient way to check where the page should be broken, but the above implementation works just fine.

On 13-Jul-09, at 5:16 PM, Matt Neuburg wrote:

On Mon, 13 Jul 2009 10:07:17 -0700, "K. Darcy Otto" <do...@csusb.edu> said:

Now, this should simply print a line of integers down the left side of the page. It does this for two pages - works perfectly - with lines 0
to 50 on the first page, and 51 to 100 on the second page, divided
correctly so there is no splitting of lines and so on. But the rest of
the pages are blank, and I can't figure out why.  The NSLog from -

Again, you're not providing enough information, but here are some questions
to ask yourself.

* What's printing is a view. How tall is that view? Is it tall enough to
contain 500 lines?

* Also: In drawRect:(NSRect)rect, what is rect?

_______________________________________________

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 arch...@mail-archive.com

Reply via email to