Menu

#1169 Can't create highlight note with AppleScript

Other
closed
nobody
5
2017-03-07
2017-03-07
No

Trying to create a hilite note in a PDF file with AppleScript:

set theText to "PostGreSQL"
tell application "Skim"
tell document 1
set theSel to find it text theText
set theNote to make new note with properties {type:highlight note, note selection:theSel}
end tell
end tell

throws an error:
„characters 1420 thru 1429 of text of page 2 of document "BEXIS281_Installation_Manual.pdf"“ cannot be read (translation from German). number -1728 from characters 1420 thru 1429 of text of page 2 of document "BEXIS281_Installation_Manual.pdf"
This did work in Skim 1.4.9, but does not in version 1.2.26 and 1.2.27.

Mac OS X Yosemite 10.10.5 on MacBook Pro (13 inch, mid 2012),

Discussion

  • Christiaan Hofman

    I am prettuy sure also 1.4.9 won't work for you. This was broken by the OS, not by Skim. AppleScript support has always been has always been pretty bad, especially when it comes to this kind of selections (but it also offers no alternative).

    You should not pass the selection as a property in the record, but as a "with data" argument, that should work in 10.10:

    make new note with data theSel with properties {type:highlight note}

     
    • Thomas Fischer

      Thomas Fischer - 2017-03-07

      Hello Christiaan,

      Am 07.03.2017 um 17:13 schrieb Christiaan Hofman hofman@users.sf.net:

      I am pretty sure also 1.4.9 won't work for you. This was broken by the OS, not by Skim. AppleScript support has always been has always been pretty bad, especially when it comes to this kind of selections (but it also offers no alternative).

      I tested it with 1.4.9 before filling in the bug report, and it worked.

      make new note with data theSel with properties {type:highlight note}

      works with 1.4.27 :-)
      but not with 1.4.9 :-(

      But thanks for the quick response and the helpful hint – wouldn't have thought of that!

      Cheers
      Thomas

       
      • Christiaan Hofman

        Yes, the "with data" option was added precisely because of this bug in AppleScript support on Yosemite, so it was not yet supported in 1.4.9.

        It is strange that this was working in 1.4.9, because our handling of of the properties and the selection is essentially the same. We only added the support for "with data" as a workaround. Somehow AppleScript support must be broken already by the compiler, as our handling of the properties and selections is essentially the same as it was for 1.4.9 (except for the handling of "with data" as an alternative). In fact, when I use the code from 1.4.9, but compiled with Xcode 8, it also fails, even though 1.4.9 compiled in 2014 apparently works.

         
  • Christiaan Hofman

    • status: open --> closed
     

Log in to post a comment.