• 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
Using NSImage to create high res images on disk for use in a webview (that will be printed)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Using NSImage to create high res images on disk for use in a webview (that will be printed)
      • From: George Orthwein <email@hidden>
  • Prev by Date: QTMovie(s) and Threads
  • Next by Date: Re: Running out of process VM
  • Previous by thread: Re: QTMovie(s) and Threads
  • Next by thread: Re: Using NSImage to create high res images on disk for use in a webview (that will be printed)
  • Index(es):
    • Date
    • Thread