Pasting text and images together

Paul Dupuis paul at researchware.com
Mon Sep 4 16:03:43 EDT 2023


Do you have access to the Apple Developer web site?

A search didn't tell me much but I find the side terrible useless. 
Following a bunch of variable type definitions I wandered to this page: 
https://developer.apple.com/documentation/foundation/nsattributedstring/1530578-rtfd

Which also seemed useless to me. I was hoping to find some documentation 
that explicitly explained the format, rather than Apple API's to access 
the format.

The Wikipedia entry seemed more helpful 
(https://en.wikipedia.org/wiki/Rich_Text_Format_Directory) - it appears 
teh format is a "bundle" (or folder) of files, including an RTF file and 
how ever many media files.

While I don't fully follow this Stackoverflow discussion 
(https://stackoverflow.com/questions/18722314/how-to-get-rtf-contents-from-uipasteboard-after-uiwebview-copy) 
it appears the clipboard contents is UTF8 encoded, so perhaps doing a 
textDecode of UTF8 and then looking at the result may be helpful?



On 9/4/2023 3:36 PM, David Epstein via use-livecode wrote:
> I do not know how my problems accessing the rawClipboardData were overcome, but I succeeded in reading the array values there.  So I was able to address my original question of how to reconstruct in LiveCode a combination of text and image copied from another program.  Conclusion thus far:  no success.  If anyone is interested in this and might have some further suggestions, read on.
>
> When I use the control key to invoke from the contextual menu “copy image” on a web page, the fullClipboardData[“image”] gets a string of humanly unintelligible characters that, when used as the text of a LiveCode image object, shows the copied image.   I did this for the picture of Robert Cailliau on webpage https://livecode.com/core-benefits-of-livecode/.  Call this String A.
>
> To see how this information might be stored when I have copied both text and image, I selected from the word before to the word after that same picture, chose “Copy,” and then inspected the rawClipboardData["com.apple.flat-rtfd”], which seemed the most promising candidate of the various clipboardData array values.  Call this String B.
>
> Something that looks kind of like String A appears in String B, but it is not the same.
>
> At char 4097 of String B I see the first few characters of the beginning of String A, and think this might define the PNG data to follow.  But what follows is not the same as String A.
>
> Here’s the start of string A:
>
> âPNG
> IHDR,,y}éusRGBÆŒÈDeXIfMM*ái††,†,ÿ`ÇÁ@IDATxÏΩ
>
> And here’s char 4097ff of String B;
>
> âPNG
> IHDR,,y}éu IDATxúÏΩ{¨mYv÷˜sƵˆ„ÏÛ∏˜ú{Îvuuwuπ‹.€Ìˆ«!,d«2$qä¯a«9éCj,d°!dÅ"EâàB
>
> So my hope that String A could somehow be extracted from String B and used to “paste” the included image was disappointed.
>
> David Epstein
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list