I wanted to add a more comfortable way to add symbols to a PDF - a bit like in word because Alt+code or copy paste from the character table is a bit tedious.
I saw that this has been already a thing in the past.
viewtopic.php?t=22979
I added a custom tool using JavaScript that does that
But when I have selected a text field with the cursor inside the text the symbol is only added after I deselect the text (sometimes when I wait too long with the deselect it's not added at all).
When the text is just selected it works without any problem
That's the function:
Code: Select all
function addGreekLetter(doc) {
var textAnnot = doc.selectedAnnots[0]
const originalText = textAnnot.contents;
const symobToBeAdded = greekLetterToBeAddedGlobal
const newText = originalText + symobToBeAdded;
textAnnot.setProps({
contents: newText,
});
}
Could anyone help me how to achieve this?
Like updating the text/deselecting it automatically?
I'd be happy to share the code here with anyone who find it useful when that works.
Best,
Niklas