Skip to main content
Pedro Cortez Marques
Legend
March 24, 2015
Question

Create Annotations with 'author' name tool property

  • March 24, 2015
  • 0 replies
  • 183 views

Philip Cord has kindly sent me this code that allows to create annotations with the "Author" tool property (older versions than CS3 couldn't get this on script listener - only on the CS3 script listener).

Hope it helps anyone like me that can't have access anymore to CS3


var colour = new SolidColor();

colour.rgb.hexValue = 'ff00ff';

selectNote(0);

colourNote(colour);

addAuthorToNote("Author Name");

function colourNote(colour) {

var Saturation = colour.hsb.saturation;

var Brightness = colour.hsb.brightness;

var Hue =colour.hsb.hue;

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putEnumerated( stringIDToTypeID('annotation'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc.putReference( charIDToTypeID('null'), ref );

var desc2 = new ActionDescriptor();

var desc3 = new ActionDescriptor();

desc3.putUnitDouble( charIDToTypeID('H   '), charIDToTypeID('#Ang'), Hue );

desc3.putDouble( charIDToTypeID('Strt'), Saturation );

desc3.putDouble( charIDToTypeID('Brgh'), Brightness);

desc2.putObject( charIDToTypeID('Clr '), charIDToTypeID('HSBC'), desc3 );

desc.putObject( charIDToTypeID('T   '), stringIDToTypeID('annotation'), desc2 );

executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

};

function selectNote(number) {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putIndex( stringIDToTypeID('annotation'), number );

desc.putReference( charIDToTypeID('null'), ref );

try{

executeAction( charIDToTypeID('Shw '), desc, DialogModes.NO );

}catch(e){}

};

function addAuthorToNote(Author) {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putEnumerated( stringIDToTypeID('annotation'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc.putReference( charIDToTypeID('null'), ref );

var desc2 = new ActionDescriptor();

desc2.putString( charIDToTypeID('Athr'),  Author);

desc.putObject( charIDToTypeID('T   '), stringIDToTypeID('annotation'), desc2 );

executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );

};

function makeAnnotation(X,Y,Width,Height) {

var desc = new ActionDescriptor();

var ref = new ActionReference();

ref.putClass( stringIDToTypeID('annotation') );

desc.putReference( charIDToTypeID('null'), ref );

var desc2 = new ActionDescriptor();

var desc3 = new ActionDescriptor();

desc3.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), X );

desc3.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), Y );

desc2.putObject( charIDToTypeID('Lctn'), charIDToTypeID('Pnt '), desc3 );

var desc4 = new ActionDescriptor();

desc4.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), Width );

desc4.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), Height );

desc2.putObject( charIDToTypeID('Sz  '), charIDToTypeID('Ofst'), desc4 );

desc2.putEnumerated( stringIDToTypeID('annotType'), stringIDToTypeID('annotType'), stringIDToTypeID('annotText') );

desc.putObject( charIDToTypeID('Usng'), stringIDToTypeID('annotation'), desc2 );

executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );

};

This topic has been closed for replies.