• 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: Report printing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Report printing


  • Subject: Re: Report printing
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Thu, 20 Nov 2003 19:36:08 -0800

Hello...

I think the reason that your headerView needs to be set as a subview of the printing view is that the ability to print is basically just drawing the window and saving the image (since Cocoa uses postscript for display). When your printView is told to draw (print) itself, it also passes the draw message to all of its subviews so that they are printed. When your headerView is not a subview of your printView, it is outside of the view hierarchy that is being printed. In other words, what is being printed is the specific view (the printView) and the views that are contents of that view, not any other views that might be present. If you don't want to actually make headerView a subview of printView, you might be able to use the same method that I recommend for your recordView (see below).

What I would do, if I were trying to do this, would be to make recordView capable of printing itself , using the view from the nib, for each record, and then for each page draw in printView the PDF images from each recordView . Instead of inserting the view from the nib for each record, you would just insert the "printed" image from each recordView. I believe there is a printing method that allows you to specify the NSRect in the view for each page, and then the drawRect: method will be called with each of those rects, so at any time you will only need to have rendered recordViews stored in memory for the records that fit on each individual page.

I hope that helps...

Louis


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I have to print a report of one or more pages. Each page contains a
header followed by a variable amount of rectangles which contain the
data of a record. I've read all the available documentation on printing
and I have set up an NSView subclass for printing. According to the
documentation, I have to implement drawRect to do my output and this
also works.

Now I'm a bit lazy and I'd prefer to have a graphical tool to layout
the fields of the header and of the records instead of hard-coding
every text output. So I have created a nib file which contains small
custom views, one for the header and one for records. The idea is that
my PrintView loads this nib, places the views correctly and they get
printed automatically when print: is called. In pseudo-code, this is
what I hope to do:

- - drawRect (of PrintView)
{
compute and set the frame of HeaderView
set text fields of HeaderView with general information
display HeaderView

for each record that I want to print do
compute and set the frame of RecordView
set text fields of RecordView with record information
display RecordView (by calling -display or by directly calling
- -drawRect of RecordView)
end for
}

I'd like to have only one instance of RecordView which I can reuse as
many times as necessary in drawRect. Now... If I add HeaderView as
subview to PrintView, then it really gets printed. If it's not a
subview of PrintView, no output is generated. Question 1: Why is this?
Can I avoid having to attach HeaderView and RecordView to PrintView and
still get an output on paper?

Problem 2: The record-displaying part does not work. Only the last
record at the last position is printed on the page. Do I really have to
instantiate RecordView for every record? If so, is there a better way
to do it than to reload the nib for every new instance? Can I somehow
copy a view (NSView does not implement the NSCopying protocol, as far
as I've seen)?

Thanks for any help!

Beat


PS: Does anybody know a Cocoa reporting tool?


- -----
Beat Koch Informatik, Im Taeli 8, CH-3052 Zollikofen, Switzerland
Phone: +41 (31) 914 23 51, Fax: +41 (31) 914 23 52

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBP7yy0ezksbVDbluoEQLeVwCeIXdO7LwDv1WR4f8PL5gXx5yCRTgAn38x
TOYDo6tQXUaWGQB8X4+pA5qg
=8oVn
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Report printing (From: Beat Koch <email@hidden>)

  • Prev by Date: Re: SearchKit vs. Lucene
  • Next by Date: Re: Don't leak memory!!
  • Previous by thread: Report printing
  • Next by thread: Re: Report printing
  • Index(es):
    • Date
    • Thread