• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: multiple-page print support in NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiple-page print support in NSView


  • Subject: Re: multiple-page print support in NSView
  • From: Rua Haszard Morris <email@hidden>
  • Date: Thu, 8 Apr 2010 08:24:00 +1200

>> I am trying to write an NSView subclass to render a multi-page printout. What I would like is to use the page/paper size in calculating the dimensions of each page; for example, if the printout is made up of N rows of items, each item rendering as 60-point-tall row.
>>
>> So, assuming 10 rows of items, the rendered view needs to be 10 * 60 pt high, and the page boundaries need to be set appropriately - if the usable paper area is 120 points high, then we need 5 pages of 2 rows, and if the user specifies much larger paper, e.g. 240 points, then we need 3 pages, each with up to 4 rows (the last page only having two rows).
>>
>> How do I implement knowsPageRange, rectForPage, and locationOfPrintRect to achieve this?
>>
>> I have tried implementing these methods to set up arbitrary rectangles for each page, and I find that the rendering I do in drawRect is scaled weirdly in the printout, with a huge (half the page) right margin and an even huger (more than half the page, proportional to the total number of pages) top margin.
I found my problem - I needed to set the pagination options on the NSPrintInfo appropriately, otherwise the automatic pagination interacts with my custom pagination. The trick was to implement print: myself and set up the NSPrintInfo and the current NSPrintOperation, so the rest of my view code could successfully query the page size, margins etc.

   NSPrintOperation* po = [NSPrintOperation printOperationWithView:self];
   NSPrintInfo *pInfo = [po printInfo];
   [NSPrintOperation setCurrentOperation:po];
   [pInfo setHorizontalPagination:NSFitPagination];
   [pInfo setVerticalPagination:NSClipPagination];

>> Is there sample code or a tutorial somewhere that explains how to set up custom page coordinates? I have read through "Printing Programming Topics for Cocoa", and it seems I'm missing something critical here.
> That is pretty much it other than sample code. Are you aware of the sample code listings that come with each class reference document? Other than that, the only difficult-to-find documentation that is a real hiney-biter is that text is always rendered in a flipped coordinate system.
Good point, I see there are a range of Sketch related and other samples listed in the links for NSPrintOperation, NSPrintInfo.

I should mention that the documentation changed a lot over the weekend, the new Printing Programming Topics for Cocoa is slightly more helpful!

thanks for the advice
Rua HM.

--
http://cartoonbeats.com

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >multiple-page print support in NSView (From: Rua Haszard Morris <email@hidden>)
 >Re: multiple-page print support in NSView (From: Keary Suska <email@hidden>)

  • Prev by Date: Re: copy/paste in modal window
  • Next by Date: iPad: UIImagePickerController
  • Previous by thread: Re: multiple-page print support in NSView
  • Next by thread: Xcode build settings (such as llvm-config)
  • Index(es):
    • Date
    • Thread