Hi,
I was wondering if there is any way for Photoshop to automatically change the value of a text field before printing.
At the moment i am printing gift vouchers 4 to a page and have to manually change the 3 digit serial number in each voucher before printing.
I realise that In Design could probably do this in seconds but I don't have access to that software (or the skills to use it )
Is there some way of scripting things so that the text fields would automatically change before being sent to print.
I am not using a large volume of these so it is not too onerous a task to do it by hand, but it is rather repetitive and boring.
Thanks for reading and I'd be grateful if anyone can suggest any possible solutions
Kenny
Auto Numbering in photoshop
Auto Numbering in photoshop
Assuming you are talking about type layers without anything fancy (like combining different fonts, sizes, …) it seems feasible.
But why 3 numbers? Don’t you need to change all 4?
But why 3 numbers? Don’t you need to change all 4?
Auto Numbering in photoshop
Sorry. I meant three digits.
In all four cases.
The font and size is standardised In the text fields.
Thanks
In all four cases.
The font and size is standardised In the text fields.
Thanks
Auto Numbering in photoshop
Are those four the only type layers in the document?
If not how are they identifiable?
If not how are they identifiable?
Auto Numbering in photoshop
yes,
these are the only text fields.
at the moment they are identified by their contents but I can call them anything you care to suggest.
Thanks
Kenny
these are the only text fields.
at the moment they are identified by their contents but I can call them anything you care to suggest.
Thanks
Kenny
Auto Numbering in photoshop
This code will not be very fast, but it might suffice, so please give it a try:
Code: Select all// this script increases the numbers in type layers;
// it needs all type layers to contain only numbers, though;
// 2013, use it at your own risk;
#target photoshop;
if (app.documents.length > 0) {
// get doc;
var myDocument = app.activeDocument;
// the type layer;
var typeLayers = collectTypeLayers(myDocument, []);
// add to numbers;
for (var m = 0; m < typeLayers.length; m++) {
var theNumber = typeLayers[m].textItem.contents;
typeLayers[m].textItem.contents = Number(theNumber) + typeLayers.length;
}
};
//that’s it; thanks to xbytor;
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
var theNumberString = String(number);
for (var o = 0; o < (places - String(number).length); o++) {
theNumberString = String("0" + theNumberString)
};
return theNumberString
};
////// function collect type layers //////
function collectTypeLayers (theParent, allLayers) {
if (!allLayers) {var allLayers = new Array}
else {};
for (var m = theParent.layers.length - 1; m >= 0;m--) {
var theLayer = theParent.layers[m];
// apply the function to layersets;
if (theLayer.typename == "ArtLayer") {
if (theLayer.kind == LayerKind.TEXT) {allLayers.push(theLayer)}
}
else {
allLayers = (collectTypeLayers(theLayer, allLayers))
// this line includes the layer groups;
allLayers.push(theLayer);
}
};
return allLayers
};
Code: Select all// this script increases the numbers in type layers;
// it needs all type layers to contain only numbers, though;
// 2013, use it at your own risk;
#target photoshop;
if (app.documents.length > 0) {
// get doc;
var myDocument = app.activeDocument;
// the type layer;
var typeLayers = collectTypeLayers(myDocument, []);
// add to numbers;
for (var m = 0; m < typeLayers.length; m++) {
var theNumber = typeLayers[m].textItem.contents;
typeLayers[m].textItem.contents = Number(theNumber) + typeLayers.length;
}
};
//that’s it; thanks to xbytor;
////// buffer number with zeros //////
function bufferNumberWithZeros (number, places) {
var theNumberString = String(number);
for (var o = 0; o < (places - String(number).length); o++) {
theNumberString = String("0" + theNumberString)
};
return theNumberString
};
////// function collect type layers //////
function collectTypeLayers (theParent, allLayers) {
if (!allLayers) {var allLayers = new Array}
else {};
for (var m = theParent.layers.length - 1; m >= 0;m--) {
var theLayer = theParent.layers[m];
// apply the function to layersets;
if (theLayer.typename == "ArtLayer") {
if (theLayer.kind == LayerKind.TEXT) {allLayers.push(theLayer)}
}
else {
allLayers = (collectTypeLayers(theLayer, allLayers))
// this line includes the layer groups;
allLayers.push(theLayer);
}
};
return allLayers
};