Using viewer 201
I noticed when pasting an annotation from either the same pdf or another, EVERYTHING is pasted, including creation date, modification date, author, and readOnly status. I am about to delve into the documentation looking, but figured it couldn't hurt to throw this question out as I don't see it on first, second, or third glance, but I would like to perhaps change a few things about an annotation when I paste it, specifically the readOnly bit, but perhaps also the author and the creation date.
My reasoning is we lock all annotations at save time, so if a user opens a 'complete' document, and copies a locked annotation (lets say created by someone else entirely), and then goes and loads a new document, and pastes said annotation, it is also read only.
Alternatives I will look into are: not allowing pasting (last resort really), not allowing copying of read-only annotations (I would be ok with this), or just some easy way to trigger when it happens and I can go in and update said annotation(s).
Pasting annotations - is there an event?
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 14
- Joined: Thu Feb 17, 2011 4:25 pm
-
- Site Admin
- Posts: 2445
- Joined: Thu Jun 30, 2005 4:11 pm
Re: Pasting annotations - is there an event?
Hi, schmoli.
I can suggest you one solution, not simple but it will work..
Add code to process event about changing the selection.
HTH
I can suggest you one solution, not simple but it will work..
Add code to process event about changing the selection.
Code: Select all
pdfViewer.SetProperty("Notifications.Selection.Filter", -1);
....
function OnEvent(Type, Name, DataIn, DataOut, Flags)
{
if (Type == PXCVA_OnNamedNotify) and
(Name == "Notifications.Selection") then
{
string annotSelIsReadonly;
pdfViewer.GetProperty("Notifications.Selection.Document", DataOut, 0);
int docID = DataOut;
pdfViewer.DoDocumentVerb(docID, NULL, "GetSelectedAnnot", DataIn, DataOut, 0);
int pageIndex = DataOut[0];
if (pageIndex >= 0)
{
int annotIndexOnPage = DataOut[1];
pdfViewer.RunJavaScript("var aa = this.getAnnots(" + pageIndex + "); if (aa.length) aa[" + annotIndexOnPage + "].readOnly;", out annotSelIsReadonly, docID, 0);
}
string cmdState = "Online";
if (annotSelIsReadonly == "true")
cmdState = "Offline";
pdfViewer.SetProperty("Commands["Copy"].State", cmdState, 0);
pdfViewer.SetProperty("Commands["Cut"].State", cmdState, 0);
}
}
PDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 14
- Joined: Thu Feb 17, 2011 4:25 pm
Re: Pasting annotations - is there an event?
I forgot to reply when I solved this but what I did is examine the annotations before the paste operation, and then again after -- any new annotations I was able to find I update whatever properties I need to change.
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Pasting annotations - is there an event?
Thanks and pleased to hear you got there ....
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com