• 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: Put pdf on pasteboard / NSData from NSImage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Put pdf on pasteboard / NSData from NSImage?


  • Subject: Re: Put pdf on pasteboard / NSData from NSImage?
  • From: Geoff Levner <email@hidden>
  • Date: Sat, 9 Apr 2005 06:42:42 +0200

You can copy a PDF image representation to the pasteboard like this:

+ (void) copyPDFToPasteboard:(NSPDFImageRep*)pdfRep
{
    NSPasteboard *pb = [NSPasteboard generalPasteboard];
    NSArray *types = [NSArray arrayWithObject:NSPDFPboardType];
    [pb declareTypes:types owner:nil];
    [pb setData:[pdfRep PDFRepresentation] forType:NSPDFPboardType];
}

If you don't have a pointer to the PDF image representation, you can get it through NSImage's -representations method like this:

+ (NSPDFImageRep*) getPDFRepFromImage:(NSImage*)image
{
    NSArray *reps = [image representations];
    int i, n = [reps count];
    for (i = 0; i < n; i++) {
        NSImageRep *rep = [reps objectAtIndex:i];
        if ([rep isKindOfClass:[NSPDFImageRep class]])
            return (NSPDFImageRep*) rep;
    }
    return nil;
}

Geoff

On 9 Apr 2005, at 03:23, Julian Dreißig wrote:

I have a NSImage loaded with a pdf (e.g. pasted into). How can I put this pdf on a pasteboard? As far as I can see I need the image in a NSData representation (-setData:forType:). How do I get such a NSData from a NSImage _without_ showing the image in a NSView?
Or is there an easier way to do what I want to do?


Thanks a lot,
- Julian

_______________________________________________ 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: Put pdf on pasteboard / NSData from NSImage?
      • From: Julian Dreißig <email@hidden>
References: 
 >Put pdf on pasteboard / NSData from NSImage? (From: Julian Dreißig <email@hidden>)

  • Prev by Date: NSTableColumn setIndicatorImage in the wrong place?
  • Next by Date: Re: Odd problem using NSCoding
  • Previous by thread: Put pdf on pasteboard / NSData from NSImage?
  • Next by thread: Re: Put pdf on pasteboard / NSData from NSImage?
  • Index(es):
    • Date
    • Thread