Printing many, many pages efficiently
-
Hi all,
I want to print many, many records from a database. And I do! Printing
goes well. All is fine.
The question:
How can I set up the printing machinery to call my code once for each
page, so that I can build that page just before it is printed, and then
release it, its subviews and its associated data before building the
next page?
From what I understand, it seems you have to provide the entire NSView
to be printed, and feed that into printOperationWithView: before the
actual printing even starts. I would really like to avoid this, as it
consumes a lot of memory. Also it is rather wasteful to have to build a
view spanning over, say, 100 pages (loading maybe 1000 records from my
database), if the user only wants to print a small range of pages.
Very grateful for any input!
thanks
/jacob
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
On Tuesday, December 3, 2002, at 03:36 PM, Jacob Engstrand wrote:
> The question:
> How can I set up the printing machinery to call my code once for each
> page, so that I can build that page just before it is printed, and
> then release it, its subviews and its associated data before building
> the next page?
I don't think there's a generic answer to this. If your information is
of a set size(e.g. 10 database rows per page) or if the size can be
determined relatively easily, then you could relatively easily code it
to be more efficient. However, if the printed length of each database
row is variable, I'm not sure that there's any easy way to make
printing more efficient.
Just my 2"...
Jeff
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
What I've done is this: Subclass NSView (in my case I subclass
NSImageView). In the subclass, implement -knowsPageRange, returning NO
(this turns off AutomaticPagination), and implement -rectForPage. The
latter is called just before printing each page, its parameter is the
page number. You'll have to work out what goes on each page, though.
I'm not releasing the view, which was passed to
-printOperationWithView:. I'm just setting new contents for each page
inside -rectForPage.
For a good discussion of printing, get the Scott Anguish book from SAMS,
Cocoa Programming.
Paul Collins
Gracion Software
On Tuesday, December 3, 2002, at 12:36 PM, Jacob Engstrand wrote:
> The question:
> How can I set up the printing machinery to call my code once for each
> page, so that I can build that page just before it is printed, and then
> release it, its subviews and its associated data before building the
> next page?
** Gracion Software http://www.gracion.com/ **
** Tel: +1 (541) 488-3488 **
** DigiTunnel 1.1 PPTP/VPN client for OS X **
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
On tisdag, dec 3, 2002, at 23:23 Europe/Stockholm, Jeff LaMarche wrote:
> On Tuesday, December 3, 2002, at 03:36 PM, Jacob Engstrand wrote:
>
>> The question:
>> How can I set up the printing machinery to call my code once for each
>> page, so that I can build that page just before it is printed, and
>> then release it, its subviews and its associated data before building
>> the next page?
>
> I don't think there's a generic answer to this. If your information is
> of a set size(e.g. 10 database rows per page) or if the size can be
> determined relatively easily, then you could relatively easily code it
> to be more efficient. However, if the printed length of each database
> row is variable, I'm not sure that there's any easy way to make
> printing more efficient.
>
Hi & thanks.
Well, one can _sort of_ do it in rectForPage:... That's what I'm doing
now. Actually, I manage to do everything I want except removing any
subviews from the "page view". (Why are the subviews needed once they
are already printed?)
Anyhow, rectForPage: clearly isn't meant to be used this way. It would
be really nice to find the "proper" way.
/jak
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
On Tue, 3 Dec 2002 21:36:11 +0100, Jacob Engstrand <jacobengstrand...> said:
> How can I set up the printing machinery to call my code once for each
> page
See the documentation on knowsPageRange and rectForPage. For an example, look at the PaginatingViews.html document that's on your hard disk. Essentially, your NSView can be just one page long, and you simply keep redraw its contents each time drawRect is called. m.
matt neuburg, phd = <matt...>, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored. -
On onsdag, dec 4, 2002, at 02:52 Europe/Stockholm, matt neuburg wrote:
>> How can I set up the printing machinery to call my code once for each
>> page
>
> See the documentation on knowsPageRange and rectForPage. For an
> example, look at the PaginatingViews.html document that's on your hard
> disk. Essentially, your NSView can be just one page long, and you
> simply keep redraw its contents each time drawRect is called. m.
Hi Matt,
That's about what I've been doing so far, and it sort of works, but it
feels a bit like -rectForPage wasn't meant to be used in this fashion.
I just thought there would be another way. But "if it ain't fixed -
break it", I guess.
thanks
/jak
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.



