• 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
Re: reading postscript file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading postscript file


  • Subject: Re: reading postscript file
  • From: mmalcolm crawford <email@hidden>
  • Date: Wed, 28 Jan 2004 12:36:53 -0800

On Jan 28, 2004, at 9:07 AM, So Hok Chun, Bill wrote:

I tried to read a postscript file and display it in an NSImageView in Panther.
However, it seems that Cocoa interprets my PS file as an A4 size (or Letter size. i don't know) image when I do something like:
bcImage = [[NSImage alloc] initWithContentsOfFile:@"test.ps"];
The whole page is white and my image appears at the button left corner of the page.
How can I tell Cocoa/Core Graphics to crop the white space automatically? Or is there any way to ask tell Cocoa not to treat my image as a page?
Attached is the raw postscript file.

Umm, well, the document isn't properly structured -- you haven't specified a bounding box. In the absence of that, CG will do the best it can and default to (I believe) US Letter size. Moreover you've given the document type as PS, not EPS.

As ever, I can't find the DSC references on Adobe's site, but here's one version:
<http://www-cdf.fnal.gov/offline/PostScript/5002.PDF>

Minimally, if you replace the first few lines of your document with:

%!PS-Adobe-2.0 EPSF-3.0
%%Creator: libbarcode
%%BoundingBox: 5 5 115 95

% BoundingBox x-y coordinates lower-left, x-y coordinates upper-right corner of the image
% Allowing about 5 points space around the image...

you should get the result you want.

mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >reading postscript file (From: "So Hok Chun, Bill" <email@hidden>)

  • Prev by Date: Re: Images in folder - simple question?
  • Next by Date: Re: Images in folder - simple question?
  • Previous by thread: Re: reading postscript file
  • Next by thread: UML Tool
  • Index(es):
    • Date
    • Thread