• 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: Disabling Display of JPG and PDF Files in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disabling Display of JPG and PDF Files in NSTextView


  • Subject: Re: Disabling Display of JPG and PDF Files in NSTextView
  • From: Heinrich Giesen <email@hidden>
  • Date: Thu, 15 Sep 2005 10:45:21 +0200


NSTextView automatically displays JPG and PDF as images, instead of icons,
and while many people would be thrilled with this feature, I don't want it.

Once you know what textAttachment contains jpg or pdf data you could do this in the textView with the attachment

[(NSCell *)[attachment attachmentCell]
setImage:[NSImage imageNamed:@"theIcon.icns"]];
// update the textView:
[[self layoutManager] textContainerChangedGeometry:[self textContainer]];


The textView now shows the icon instead of the jpg pdf image.

.... until I reopened one of my saved files, clicked on
one of those
icons to see that after I closed the document and re-opened it, there
seemed to
be no data stored in the attachment.

If you save your textView with: [textView writeRTFDToFile:filename atomically:YES]; the imageData (jpg, pdf ... ) are correctly saved in the RTFD directory. The icon itself is not saved.

BTW: asking the filePath for the suffix @"jpg" or ... is not save.
I always find images that have the suffix @"jpg" but are bmp-images
or gif or tiff or ...
I think it is better to test the "magic number" of an image. For
jpg-Images the first 3 byte (regularFileContents of the wrapper)
must be 0xFF, 0xD8, 0xFF.

--
Heinrich Giesen
email@hidden


_______________________________________________ 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: Disabling Display of JPG and PDF Files in NSTextView
      • From: "Kirt Cathey" <email@hidden>
  • Prev by Date: Re: Simple question
  • Next by Date: Re: Disabling Display of JPG and PDF Files in NSTextView
  • Previous by thread: Re: Disabling Display of JPG and PDF Files in NSTextView
  • Next by thread: Re: Disabling Display of JPG and PDF Files in NSTextView
  • Index(es):
    • Date
    • Thread