Re: Saving window to a PDF File
Re: Saving window to a PDF File
- Subject: Re: Saving window to a PDF File
- From: dreamcat7 <email@hidden>
- Date: Sat, 1 Nov 2008 11:45:43 +0000
On 1 Nov 2008, at 10:20, <email@hidden> <email@hidden
> wrote:
I'm not sure this is actually what I want to do. Basically at the
moment I
have a window with a tableview, and I want to save the contents of the
table with some other stuff to a PDF file.
I've been reading up on it all as a print operation, and it looks
like I
will need to create a new view so I can customise it from my window,
and
print that to a PDF.
You can write a method in Cocoa that draws its objects onto an NSView.
Because a tableview has scrollbars, then printing the tableview wont
work. You will want to create an NSString which corresponds to each
row of the table view and draw that to the NSView. You can draw
anything you like into the NSView programmatically. NSString -
drawInRect: withAttributes:
Can anyone advise me on what type of view might be best?
I've got a new window, and now I need to add a view, I'm thinking I
could
add a box, and add the text and table in there and that will save to a
PDF?, or would it be easier to use a webView and use HTML to layout
the
data?
Since you appear to be sourcing the data from a tableview in Cocoa,
then it would probably make more sense to do it the Cocoa way as shown
in the printing chapter of Arron Hillegass book. A WebView is useful
if you also need to put it up on the Web. That might be achieved
(AFAIK) by writing out NSAttributed strings (Rich Text Format) and
then converting to HTML with the appropriate method. Visually, the
result would look different and rely on a CSS Stylesheet. Thats also
going to result a very different kind of a look to the document which
(may or may not be) worth the extra effort and its almost certainly
not to be recommended unless you are also competent in CSS / HTML or
will yield a very poor - quality result.
The end result will need a header area with standard details,
followed by a
table with a variable number of rows, followed by a footer area with
standard details and possible a textfield.
Try creating an NSView first and printing things out on in. Then
theres the familiarity gained to be able to draw the items
specifically wanted.
I'm working on a cocoa application, not a document based one, so I
can't
really follow Ch 27 of the Cocoa Programming book as it deals with
documents?
No, but its generally easier to follow if you do it on a .xcodeproj of
the document - based raiseman application first. Otherwise you can
have a go at 'translate' everything from the raiseman example into
your application but may find highly confusing as to do it that way
would be like learning two separate things at the same time and might
find that just a bit too confusing. - but it shouldnt be!
Thank You,
amy
_______________________________________________
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
_______________________________________________
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