I think this will probably do:

- (void) renderToPDFFile: (NSString*) text :(NSString*) file {
        NSRect r = NSMakeRect(0, 0, 800, 800);  
        NSTextView* v = [[NSTextView alloc] initWithFrame:r];
        [v setHidden:YES];
        [v insertText:text];    
        [v sizeToFit];                  // ah, the magic elixir!
        r = [v bounds];                 // now it is the right size
        NSData *data = [v dataWithPDFInsideRect:r];     
        [data writeToFile:file atomically:YES];
        [v release];
}

It seems that the sizeToFit method only effects the width of the view, but that's probably okay in my case. My text will always be fairly narrow, but it could be quite tall.

Guess I better do some error checking.

Also got rid of that redundant stuff that I didn't need because there was already some stuff that could be used.


Paul
CROR
(Chief Redundancy Officer of Redundancy)



On Aug 26, 2008, at 1:22 PM, Andy Lee wrote:

On Aug 26, 2008, at 4:03 PM, Paul Archibald wrote:
        PDFImageView* pdfview = [[PDFImageView alloc] init];

[...], I see that my pdfbounds rectangle is not properly sized, but is just {0,0,0,0}.

That's because you used -init to initialize pdfView. The designated initializer for NSViews is -initWithFrame:.

--Andy



_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to