Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
7

Query tag need to place in the margin

Participant ,
Jun 26, 2023 Jun 26, 2023

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

TOPICS
Scripting
711
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 05, 2023 Jul 05, 2023

Well, that sounded a bit harsher than necessary, sorry. It's really quite simple. First, apply all the necessary settings to your object style 'AQ-sidebar' (anchored object; set the width, not the height; set auto size to height only, add a paragraph style, probably; and whatever else). Then all you need is this simple script:

 

(function () {
  app.findTextPreferences = null;
  app.findTextPreferences.appliedCharacterStyle = 
    app.documents[0].characterStyles.item("AQ");
  var ostyle = app.d
...
Translate
People's Champ ,
Jun 26, 2023 Jun 26, 2023

What error message do you get? I just tried your script and did get the error message. Then the error was pretty meaningful.

I will leave it up to you but that's pure Javascript error that you have.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 04, 2023 Jul 04, 2023

Dear Friends,

Can one one resolve this issue?

I have no idea for how to resolve this issue?

 

Thanks

kanagakumar.k

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 04, 2023 Jul 04, 2023

Honestly, the script you showed is a total mess, it can't even be salvaged.

You should ask someone to do a new script for you.

 

P.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 04, 2023 Jul 04, 2023

Thanks for your reply "Peter Kahrel"

 

OKay! i will do my best, Thank you once again.

 

KK

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2023 Jul 05, 2023

Well, that sounded a bit harsher than necessary, sorry. It's really quite simple. First, apply all the necessary settings to your object style 'AQ-sidebar' (anchored object; set the width, not the height; set auto size to height only, add a paragraph style, probably; and whatever else). Then all you need is this simple script:

 

(function () {
  app.findTextPreferences = null;
  app.findTextPreferences.appliedCharacterStyle = 
    app.documents[0].characterStyles.item("AQ");
  var ostyle = app.documents[0].objectStyles.item('AQ-sidebar');
  var AQs = app.documents[0].findText();
  var frame;
  for (var i = AQs.length-1; i >= 0; i--) {
    frame = AQs[i].insertionPoints[0].textFrames.add ({
      appliedObjectStyle: ostyle,
    });
    AQs[i].move (LocationOptions.AT_BEGINNING, frame);
  }
}());

 

P.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 18, 2023 Jul 18, 2023
LATEST

Dear Peter Kahrel

 

Please accept my heartfelt apologies for the delayed response.

Thank you for your script. It's working fine.

 

Thank you very much

KK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines