How to create pdf with alpha
How to create pdf with alpha
- Subject: How to create pdf with alpha
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 15 Oct 2011 19:55:26 +0700
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 (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