• 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
Troubles with NSView...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Troubles with NSView...
      • From: Phillip Hutchings <email@hidden>
  • Prev by Date: Re: Proper use of controllers
  • Next by Date: Looking for two (2) freelance Cocoa developers
  • Previous by thread: Re: Drawing a selection rectangle
  • Next by thread: Re: Troubles with NSView...
  • Index(es):
    • Date
    • Thread