I have been playing around with the annotation template.
My question now is, I have selected text in a pdf.
This selected text should be appended to the annotation where it reads
“Type your note here.” initially.
So my question has several sub questions.
In the template script, I can access the selected text like this
set selText to the selected text of think window 1
Around here, I can imagine that the selText could be added to the file:
set theRecord to import theTemplateFiles placeholders {|%documentName%|:theFrontmostDocumentName, |%documentLink%|:{|URL|:theFrontmostDocumentURL, |name|:my helperLibrary's localizedString("Click here to view annotated document")}} to theFirstParent
But I’m not certain.
My overall goal is to have a new template, which links excerpts (i.e., direct citations) of a pdf to that pdf. In contrast to the annotation template, which creates only one annotation, I’d like to have as many files linked to the pdf as I create excerpts.
That piece already works by deleting the section dealing with existing annotations in the annotation template script.
Rich text scripting of Mac OS X is limited to visible views/windows, otherwise the formatting isn’t preserved. Therefore you’d have to open a window for the record, modify its text and save it.
Thanks for that information.
Is it possible to do that with a script.
I know how to open the record in a window via script. But is it possible to add text to the window and save it?
Perhaps this helps. The snippet below is from a personalized script I developed for selecting and copying text in a pdf and adding it to the end of an annotation document (RTF). As I understand it, this is similar to what you’re looking to do. You’ll need to sort out the bits of this snippet that refer to local variables in my script, but you should get the general drift by examining the snippet. (I won’t be posting my whole script as it contains actions specific to my research.)
[size=85]Code Snippet - for example only; not a working routine
if theQuotationText ≠ "" then
make new paragraph with data (return & "Quotation: ") at the end of text of think window 1
make new word with data ("Page " & the theCurrentPageNumber & return) with properties {URL:theQuotationFullUrl} at the end of text of think window 1
bold last paragraph of text of think window 1
make new paragraph with data (theQuotationText & return & return) at end of text of think window 1
italicize last paragraph of text of think window 1
make new paragraph with data ("Annotation:" & return) at the end of text of think window 1
bold last paragraph of text of think window 1
end if
```[/size]