Query tag need to place in the margin
- June 26, 2023
- 3 replies
- 828 views
Dear Experts,
I believe I will get help with my request.
I found a script in our forum, and I slightly altered the characterstyle name.
My request is that my object style be applied to the anchor box; and showing error, could you possibly help?
My object style name is "AQ-sidebar"
My Character style name is "AQ"
Please see the attached file, after run the script
--------------------------
app.findTextPreferences = null;
app.findTextPreferences.appliedCharacterStyle = "AQ";
myText.appliedObjectStyle = myDoc.objectStyles.item ("AQ-sidebar");
var
mFound = app.activeDocument.findText(),
len = mFound.length,
currWidth, tarText, tarIP, currFrame, currGB,
old_VOrigin = app.activeDocument.viewPreferences.verticalMeasurementUnits,
old_HOrigin = app.activeDocument.viewPreferences.horizontalMeasurementUnits;
app.activeDocument.viewPreferences.horizontalMeasurementUnits = app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.POINTS;
while (len-->0) {
tarText = mFound[len];
currWidth = tarText.lines[0].endHorizontalOffset - tarText.lines[0].horizontalOffset + 10;
tarIP = tarText.insertionPoints[-1];
currFrame = tarIP.textFrames.add();
setFrame (currFrame);
currGB = currFrame.geometricBounds;
currGB = [currGB[0], currGB[3] - currWidth, currGB[2], currGB[3]];
currFrame.geometricBounds = currGB;
tarText.texts[0].move(LocationOptions.AFTER,currFrame.texts[0]);
currFrame.parentStory.characters[-1].remove();
currFrame.fit(FitOptions.FRAME_TO_CONTENT);
}
app.activeDocument.viewPreferences.horizontalMeasurementUnits = old_HOrigin;
app.activeDocument.viewPreferences.verticalMeasurementUnits = old_VOrigin;
app.findTextPreferences = null;
function setFrame (mAnchored){
with (mAnchored) {
anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
anchoredObjectSettings.anchorPoint = AnchorPoint.BOTTOM_RIGHT_ANCHOR;
anchoredObjectSettings.horizontalReferencePoint = AnchoredRelativeTo.TEXT_FRAME;
anchoredObjectSettings.verticalReferencePoint = VerticallyRelativeTo.LINE_BASELINE;
textFramePreferences.insetSpacing = [0,0,0,1];
textFramePreferences.verticalJustification = VerticalJustification.BOTTOM_ALIGN;
}
}
---------------------
Thanks
kanagakumar
