Move RulerOrigin using script in Indesign
I have a text frame and I want to move the ruler origin to the top left coordinates of the textframe. i.e move the zero mark to Top Left side of the text frame. I know it can be done manually but I need this in my code.
Here is the code which I have writtten but for some reason it is not setting the value.
var myDoc = app.activeDocument;
// Ensure there is a selected text frame
if (app.selection.length !== 1 || !(app.selection[0] instanceof TextFrame)) {
alert("Please select a single text frame.");
} else {
var textFrame = app.selection[0];
var txtBounds = textFrame.geometricBounds;
var txt_y = txtBounds[0].toFixed(2);
var txt_x = txtBounds[1].toFixed(2);
rulerOrigin = [txt_y,txt_x];
myDoc.viewPreferences.rulerOrigin=rulerOrigin;
I am getting following error:
Error Number: 30477
Error String: Invalid value for set property 'rulerOrigin'. Expected RulerOrigin enumerator, but received ("336.00", "103.20").
