0

My program creates adobe ai or (eps) file and I want to copy it to pasteboard. I copied sample ai object in adobe illustrator and Inspect pasteboard by "pasteboard inspector":

enter image description here

My code is below but copy nothing to pasteboard:

void copyEPS(CFDataRef data)
{
    OSStatus err = noErr;
    PasteboardRef theClipboard;

    err = PasteboardCreate(kPasteboardClipboard, &theClipboard);
    // err is 0
    err = PasteboardClear(theClipboard);
    // err is 0
    PasteboardSynchronize(theClipboard);

    err = PasteboardPutItemFlavor(theClipboard, (PasteboardItemID)1,
        CFSTR("AICB"), data, 0);
    // err is 0
    CFRelease(data);
}

How can I do it? Thankyou.

mh taqia
  • 3,506
  • 1
  • 24
  • 35

1 Answers1

0

The type string for PasteboardPutItemFlavor() is a UTI, so it probably should be set to CFSTR("com.adobe.encapsulated-postscript") in this case. Cocoa APIs can also be used with similar inputs.

Kevin Grant
  • 5,363
  • 1
  • 21
  • 24
  • I used "com.adobe.encapsulated-postscript" and eps data copied to pasteboard but InDesign or Illustrator doesnt paste It, if I use "dyn.ah62d4rv4gk8ycwndkk" as type, It paste to both that programs (accepted as eps) and everything is Ok, do you know how can generate the "dyn.ah62d4rv4gk8ycwndkk" string? I have been used UTTypeCreatePreferredIdentifierForTag, but I dont know what pass to "inTag" param to generate "dyn.ah62d4rv4gk8ycwndkk". thanks. – mh taqia Jul 19 '12 at 04:23
  • I believe `UTTypeCreatePreferredIdentifierForTag()` is the only way. In this case, `kUTTagClassOSType` and `CFSTR("AICB")` seem like good values for the first two parameters. Unfortunately I don't know if you'd get the same `dyn.*` string; I don't know if the string is the same on all Mac computers, or even if it's the same on your computer across reboots. It is probably not reliable to use as a raw string. – Kevin Grant Jul 19 '12 at 04:29
  • The "dyn.agk8ycwndkk" generated with kUTTagClassOSType and CFSTR("AICB"); – mh taqia Jul 19 '12 at 19:41