Troubles with NSView...
Troubles with NSView...
- Subject: Troubles with NSView...
- From: Daniele <email@hidden>
- Date: Mon, 2 Feb 2004 12:20:29 +0100
I need to draw a picture inside an NSVIew, then i would to export it in
a PDF file.
This is my code:
.h file:
#define thRead @"3d"
@interface COMMapView : NSObject {
NSView *mapView;
NSImage *toDraw;
}
...
Now i have a method that draw inside the NSView and print it in a PDF:
- (void) myMethod {
toDraw = [[NSImage imageNamed: thRead] retain];
mapView = [[NSView alloc] initWithFrame: NSMakeRect(0,0,800,600)]
[toDraw lockFocus];
[mapView drawRect: NSMakeRect(10,10,16,16)]; // 16x16 pict
[toDraw unlockFocus];
// export it
NSData *d = [[NSData alloc] initWithData: [mapView
dataWithPDFInsideRect: NSMakeRect(0,0,800,600)]];
[d writeToFile: @"test.pdf" atomically: YES];
[d release];
}
the output file is a 4kb PDF with nothing.... where is the mistake?
Thanx daniele
_______________________________________________
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.