• 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
How to create pdf with alpha
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: How to create pdf with alpha
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Blocks vs. life, the universe and everything
  • Next by Date: Re: How to create pdf with alpha
  • Previous by thread: Re: Blocks vs. life, the universe and everything
  • Next by thread: Re: How to create pdf with alpha
  • Index(es):
    • Date
    • Thread