i want to create a pdf with a clear (transparent) background, but cannot.

The pdf is created, looks ok, but has a white background.
What am I missing?

Here the code:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
        NSRect rect = NSMakeRect(0,0,99,99);
        GmdView *view = [[GmdView alloc] initWithFrame: rect ];
        NSData *pdfData = [view dataWithPDFInsideRect:rect];
        NSString *path = @"/tmp/a.pdf";
        NSError *outError;
        BOOL ok = [ pdfData writeToFile: path options: 0 error: &outError ];
        //      error processing omitted for brevity
}


@implementation GmdView

- (void)drawRect:(NSRect)rect 
{
        NSColor *back = [NSColor clearColor];
         [ back set];
        NSRectFill(rect);
        
        NSString *aString = @"a";
        
        NSRect bounds = [ self bounds ];
        CGFloat fontSize = bounds.size.width;
        NSFont *font = [ NSFont fontWithName: @"Times"  size: fontSize ];
        
        NSDictionary *attributes =      [ [ NSDictionary alloc ] 
initWithObjectsAndKeys: 
                                                                                
                                                [NSColor redColor],     
NSForegroundColorAttributeName,
                                                                                
                                                font,                           
NSFontAttributeName,
                                                                                
                                                nil 
                                                                ];
        NSAttributedString *as = [[ NSAttributedString alloc ] initWithString: 
aString  attributes: attributes ];
        [ as drawAtPoint: NSMakePoint(0,0) ];
}

@end

Xcode 4.2 , OS X 10.7.2


_______________________________________________

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 arch...@mail-archive.com

Reply via email to