errors when getting selected text of preview pdf in automator
I want to get the selected text in preview app for a pdf file, so I wrote an service like below, want to get the selected text, and process in an AppleScript, but always got two error dialogs, no further information, (but it works well in Safari) Could someone give the help to fix it?
(the error picture is from another post, but my errors are same)
I found two posts about the same issue, but no final helpful answers, and I cannot reply in these posts.
Extracting selected text from PDF using A… - Apple Community
Automator workflow isn’t handing over sel… - Apple Community
MacBook Pro 13″, macOS 12.6