omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. jeromecarney

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    jeromecarney

    @jeromecarney

    0
    Reputation
    589
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    jeromecarney Unfollow Follow

    Latest posts made by jeromecarney

    • RE: Rich Text Clipboard

      Jon - thanks, you set me on the right track -- the app I want to paste into (MarginNote) accepts rich text only if it's formatted as an Apple Web Archive type. Here's how I ultimately got it to work for Python 2.7, thanks to this guide on coercing HTML into an archive type:

      from objc_util import * 
      import os
      import base64
      theDefinition = '<html><head></head><body>''<font size="5">' + '<b>Hello</b> <i>world!2</i>' + '</font></body></html>'
      theData = base64.encodestring(theDefinition)
      theData = str(theData)
      theArchive = """<?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
       <dict>
        <key>WebMainResource</key>
        <dict>
         <key>WebResourceData</key>
         <data>
         """ + theData + """   </data>
         <key>WebResourceFrameName</key>
         <string></string>
         <key>WebResourceMIMEType</key>
         <string>text/html</string>
         <key>WebResourceTextEncodingName</key>
         <string>UTF-8</string>
         <key>WebResourceURL</key>
         <string>about:blank</string>
        </dict>
       </dict>
      </plist>"""
      thePasteBoard = ObjCClass('UIPasteboard')
      thePasteBoard = thePasteBoard.generalPasteboard()
      theType = "Apple Web Archive pasteboard type"
      thePasteBoard.setValue_forPasteboardType_(theArchive,theType)
      
      posted in Pythonista
      jeromecarney
      jeromecarney
    • RE: Rich Text Clipboard

      I've logged extensive hours working on a similar objective for the past two week -- outputting formatted text to the clipboard for a custom dictionary wrapper I've built for StarDict data -- but so far I've had no success.

      I've been able to coerce raw html into an rtf file, which I can then pass both to an NSData object as well as an attributed string, but there's still no way I can find -- UIPasteboard with every conceivable UTI, javascript, etc., to then send the formated data along to the clipboard. The current work around is to process the data throught Workflow, but that's slow and inelegant, especially when launched from split view.

      Is there anything in the works that would enable this functionality? It would seem to be such a basic feature.

      posted in Pythonista
      jeromecarney
      jeromecarney