Using NSImage to create high res images on disk for use in a webview (that will be printed)
Using NSImage to create high res images on disk for use in a webview (that will be printed)
- Subject: Using NSImage to create high res images on disk for use in a webview (that will be printed)
- From: Mike Zornek <email@hidden>
- Date: Fri, 14 Apr 2006 11:48:15 -0400
Hi everyone, and thanks in advance for reading my post.
So I have a Cocoa app that generates PDFs. It does this by generating HTML,
displaying that HTML in an off-screen WebView, and then uses the print
system to create a paginated PDF based on that WebView.
At the top of the PDF I have the company's name being printed, but I want to
give them the option of placing their logo up there. My thought is to add an
image well to the preferences window and have them set their logo; then in
code I will generate a file on disk (in ~/Libray/Caches/MyApp/) so that the
WebView can render an IMG tag with a SRC path that points to
"~/Libray/Caches/MyApp/company_logo.png".
Now this logo needs to be a high res logo since it will printed and I'm
having a hard time understanding what I need to do to accommodate the
various image types and resolutions that may be dropped in that image well.
My current code to generate the file is:
// before we create the PDF let's make a PNG file for the company logo
NSImage *logo = [NSUnarchiver unarchiveObjectWithData:[[NSUserDefaults
standardUserDefaults] valueForKey:CBCompanyLogo]];
[[[NSBitmapImageRep imageRepWithData:[logo TIFFRepresentation]]
representationUsingType:NSPNGFileType properties:nil] writeToFile:[self
pathToLogoCache] atomically:YES];
In doing my research I've also stumbled upon Matt Gemmell's NSImage category
which does cropping .. And it looks really cool, though I'm not sure how it
handles resolutions, if at all.
http://mattgemmell.com/source/
http://mattgemmell.com/files/source/imagecrop.tgz
I'm still open to ideas, but I don't think I'd have a problem adding a note
to the bottom of the image well stating that if they are dropping a rastered
image it should be 600dpi for optimal printing. But I'm clueless how to
handle this should they drop in an EPS file.
I've tried to read the Cocoa Drawing Guide but it seems way over my head.
And sadly none of my cocoa books seem to go into detail on how to work with
NSImage beyond some very basic situations. If someone could give me an
understanding of how I need to work NSImage to accomplish what I want I'd be
appreciative. Thanks.
~ Mike
--
Work: http://ClickableBliss.com
Play: http://MikeZornek.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden