Bates numbering

// Is document loaded?
if(layout.GetNumSheets())
{
	// retrieve and update counter
	local i;
	local data=CfgGetValue("bNumber/index");
	if(data.len())
		i=data.tointeger()
	else i=0;

	i+=1;
	CfgSetValue("bNumber/index",i);

	// create markup

	local m = layout.GetMarkupById(102);

	if(!m){
		m = layout.CreateMarkup("string");
		m.id=102;
		local f=m.font;
		f.height=10;
		f.name="Verdana";
		m.font=f;
		m.outline=false;
		m.pos=Point(0.5,0.01);
		m.color=Color(0,100,0);
	}
	// update text
	if(m)
	{
		local text=i.tostring();
		if(1){// leading zeros
			while(text.len()<6)
				text="0"+text;
		}
		m.text="{"+text+"}";
	}
}

See Results:

Script Results

All samples