JavaScript support - Annotation properties

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

krsh007
User
Posts: 17
Joined: Wed Sep 02, 2009 6:19 am

JavaScript support - Annotation properties

Post by krsh007 »

Hi All,

First of all I would like to thank all replying to my former posts quickly.

The SDK states full support to access Annotation properties. This is working well but:

Is there a way possible to set properties without affecting the modDate? Even when I set the property modDate directly, lets say to creationDate it obviously overrides and sets current date.

If this is not possible I'd like to request a change if possible that allows to manipulate annotation properties via JS without implicitely affecting other properties.

The use case behind is that when user applies stamps to a document any annotations applied might be set to read only so that further alterations will not be possible any longer - but when the modDate is affected by just applying readOnly state all annotations appear with same date in any exports and comment pane - thus tracking information is being lost ...

Cheers,
Klaus
krsh007
User
Posts: 17
Joined: Wed Sep 02, 2009 6:19 am

Re: JavaScript support - Annotation properties

Post by krsh007 »

Hi Support,

Many thanks for your replies to other posts - do you have any updates in respect to this one, please?

Thanks,
Klaus
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: JavaScript support - Annotation properties

Post by Ivan - Tracker Software »

Modification date for annotation was introduced to show when the annotation or its properties were modified.
If we do not change this data during modification of properties via JavaScript, this field will lose its meaning and usability.

HTH
PDF-XChange Co Ltd. (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
krsh007
User
Posts: 17
Joined: Wed Sep 02, 2009 6:19 am

Re: JavaScript support - Annotation properties

Post by krsh007 »

Hi,

Thanks for the reply - anyhow, the annotation property for modDate then would not make sense to be provided for write access as stated in Javascript for Adobe Acrobat API Reference (page 61/769) - the only remark regarding behaviour is made with "C" - meaning one must have sufficient rights to modify document.

When you try to set modDate with Adobe you will find that changing modDate of any comment/annotation is possible - of course setting other properties such as readonly via JS alters modDate (which appears acceptable).

When you open JS Console in Acrobat and execute the following code (provided you have a pdf doc opened with atleast one annotation you will find it working - when trying to close document you will also be prompted for saving or discarding changes ...

this.getAnnots()[0].modDate=this.getAnnots()[0].creationDate

In Acrobat the respective annotation properties show exactly the date as applied...

This raises the question as if it wouldn'd be convenient to have same behaviour in PDFXChange? It would give application developers a quite flexible tool that allows for implementing various use cases that might occur - in my given case tracking document changes through various stages till "stamped or marked finsihed by other means", where readOnly flag could be applied but keeping modDate to "real last" change except applying readOnly state.


Some Pseudcode could look like this:

var modDateSave=this.getAnnots()[0].modDate
this.getAnnots()[0].readOnly=true // assumption is that modDate implicitly changes to now()
this.getAnnots()[0].modDate=modDateSave // now annotation is readOnly but still has last modification date before applying readOnly state

Please let me know your thoughts. Please don't get me wrong but answer provided is not meeting my expectations whilst honouring your great efforts in dealing with all posts. You guys really do an excellent job!

Cheers,
Klaus
krsh007
User
Posts: 17
Joined: Wed Sep 02, 2009 6:19 am

Re: JavaScript support - Annotation properties

Post by krsh007 »

Bingo ... For all being interested in such or similar:

This solves it without necessity to change something :) but I am not sure about using something "official"...

i is index of annotation

Code: Select all

js = "this.getAnnots()[" + i + "].readOnly=true\n";
                    ax.RunJavaScript(js, out jsr, 0, 0x2);
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: JavaScript support - Annotation properties

Post by Stefan - PDF-XChange »

Hey Klaus,

Glad that you found a way to implement this, and hopefully it will help someone else too:)
Thanks for sharing with us.

Cheers,
Stefan