All I have assembled several pages of text as RTF in an offscreen NSTextView - outputTextView in the code below.
As the text was assembled in the view, I have marked the end of each page with a \page symbol in the RTF. As I have added each piece of text into the view I have determined how many pages the completed document requires. NSView *customView; customView = [[[NSView alloc] initWithFrame:NSMakeRect(0, 0, paperSize.width, paperSize.height * countPages)] autorelease]; [customView setBounds:NSMakeRect(0, 0, paperSize.width, paperSize.height * countPages)]; NSTextStorage *textStorage = [outputTextView textStorage]; NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; [textStorage addLayoutManager:layoutManager]; unsigned i; for (i = 1; i <= countPages; i++) { NSTextContainer *textContainer = [[NSTextContainer alloc] initWithContainerSize: NSMakeSize(printableArea.width, printableArea.height)]; NSTextView *textView = [[NSTextView alloc] initWithFrame: NSMakeRect( LEFT_MARGIN, // x ( BOTTOM_MARGIN + (countPages - i) * (printableArea.height + ( BOTTOM_MARGIN + TOP_MARGIN )) ), // y printableArea.width, // width printableArea.height) // height textContainer:textContainer]; [layoutManager addTextContainer:textContainer]; [textContainer release]; [customView addSubview:textView]; [textView release]; } [[outputTextView layoutManager] invalidateLayoutForCharacterRange:NSMakeRange( 0, [[outputTextView textStorage] length] ) isSoft:NO actualCharacterRange:nil]; NSPrintOperation *printOp; printOp = [NSPrintOperation printOperationWithView:customView printInfo:printInfo]; [printOp setShowsPrintPanel:TRUE]; [printOp runOperation]; I have checked carefully that the sizes of pages and print areas etc all make sense - and they do. The problem I have is that when I run the print job, the text drifts lower down each new page - by about an eigth of a page each new page. Any suggestions appreciated ! Peter _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com