Set annotations properties by their modification date

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

spock
User
Posts: 9
Joined: Tue Jul 30, 2013 4:41 pm

Set annotations properties by their modification date

Post by spock »

Hello,

Is there a way possible to set annotations properties if a condition on their modification date is respected ?
For exemple, I want to set the opacity property for annotations whose modification date is October 8, 2013.
This Javascript code does not work :

var annots = this.getAnnots({ nPage:0 });
for (var i = 0; i < annots.length; i++)
if (annots.modDate == "08/10/2013"
annots.opacity = 0.5;

I tried different date formats, but without success.

Can you help me, please ?

Thanks a lot.
Best regards.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Set annotations properties by their modification date

Post by Ivan - Tracker Software »

modDate property of annotation returns Date object (http://www.w3schools.com/jsref/jsref_obj_date.asp), not string.

One of the possible ways to solve your task is:

Code: Select all

var annots = this.getAnnots({ nPage:0 });
for (var i = 0; i < annots.length; i++)
{
  if (util.printd("mm/dd/yyyy", annots[i].modDate) == "08/10/2013")
    annots[i].opacity = 0.5;
}
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.
spock
User
Posts: 9
Joined: Tue Jul 30, 2013 4:41 pm

Re: Set annotations properties by their modification date

Post by spock »

Hello Ivan,

You're right, it's not a string !

Your code works perfectly !

Thanks a lot,

Best regards
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7371
Joined: Wed Mar 25, 2009 10:37 pm

Re: Set annotations properties by their modification date

Post by Paul - PDF-XChange »

:)
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com