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

HOW TO MAKE LETTERS BOLD

Community Beginner ,
Aug 06, 2017 Aug 06, 2017

Copy link to clipboard

Copied

Dear Experts,

I am trying to make the first row letters to bold. I am able to give shading to the cells. Please help me out to make the letters bold using Extend Scripting.

With Regards

Aghil.M

TOPICS
Scripting

Views

1.3K

Translate

Translate

Report

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 ,
Aug 07, 2017 Aug 07, 2017

Copy link to clipboard

Copied

Create a paragraph format that has Bold as one of its properties, then loop through the cells and paragraphs, and apply this paragraph format to each paragraph.

You are new to FrameMaker and don't understand it very well, so it will be difficult for you to properly learn to automate things with scripts. You have to know how to do things "by hand" through the interface so you know what you have to script. For example, I don't know how you shaded the rows, but you can define a table format that has heading row shading set by default. So if you apply the correct table format and make sure that the top rows are heading rows, then you will get your shading.

I would suggest that you take the FrameMaker course that is on Lynda.com and get familiar with how FrameMaker works. Then you will find that scripting it will make more sense.

I tell my FrameMaker scripting students that there are three keys to successfully scripting FrameMaker:

1) Understanding FrameMaker and its object model.

2) Knowing the syntax and structure of the language.

3) Knowing how to develop algorithms for solving problems.

If you are a programmer in other environments, 2 and 3 will be easier for you. But you are clearly lacking in the first key. Most posters here know the first key because they are familiar with FrameMaker but they need help with 2 and 3. Frankly, they are easier to help because they usually just need a push in the right direction.

Helping you is more difficult because you don't understand how to work in harmony with the way FrameMaker is designed. This is revealed by your question: "How do you make letters bold...?" A FrameMaker user knows that you make all of the letters in a paragraph bold by applying a paragraph format that has bold as one of its properties. So they might ask "How do I apply a paragraph format to a paragraph in FrameMaker?"

Anyway, I am not trying to be overly critical or unhelpful, but I want you to understand why you are not getting as much help on this forum as you would like. Most of us are busy and some of us make our living at scripting so we don't have a lot of time to help with the basics on how FrameMaker works. If you can invest some time in learning FrameMaker, you will have a better idea of how to perform tasks by hand and this will make it much easier to do things through automation.

-Rick

Votes

Translate

Translate

Report

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 Beginner ,
Sep 22, 2017 Sep 22, 2017

Copy link to clipboard

Copied

Hi Rick,

How are you?

So sorry for the late reply, I have read the post long back as you said i was studying the Frame Maker tool. Now i am able to understand how it works.

Regarding applying a format to a particular set of text_range. I created a "Character_Format" and i was trying to apply that to my First row content in table. Please see the below code.

if (doc.ObjectValid() ==  true ) {

    

      var tbl ;

      var textItems = flow.GetText (Constants.FTI_TblAnchor) ;

      for (var i = 0 ; i  < textItems.length ; i += 1 ) {

          

            tbl = textItems.obj ;

            var row = tbl.FirstRowInTbl ;

            var cell = row.FirstCellInRow ;

          

            if (cell.ObjectValid()) {

              

                var cell1 = cell.FirstPgf ;

                var cell_items = cell1.GetText (Constants.FTI_String) ;

              

                var tr = new TextRange() ;

                tr.beg.obj = cell1 ;

                tr.beg.offset = 0 ;

                tr.end.obj = cell1 ;

                tr.end.offset =  20;

                apply_char_format (tr)

                                

                    }

                }

              }

            

function  apply_char_format(tr) {

  

var CharFmt = doc.GetNamedCharFmt ("NEW") ;

  

  if (CharFmt.ObjectValid() == true)

  {

        var props = CharFmt.GetProps() ;

       doc.SetTextProps (tr, props);

       alert("FORMAT APPLIED") ;

    }

}

    

The code is  getting executed, but few places  i can see that it didnt got applied to few tables. Please see the image below.

"tr.end.offset" i have given the maximum value. I think there is some mistake i am doing in that highlighted text,Please guide me to solve this issue.

With Regards

Aghil.M

Votes

Translate

Translate

Report

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 ,
Sep 22, 2017 Sep 22, 2017

Copy link to clipboard

Copied

Since you want the entire paragraph to be bold, there is no reason to use a character format. Instead, apply a paragraph format that specifies bold to the entire paragraph. This is much easier than applying a character format. Here is a function that will apply a paragraph format to a paragraph.

var doc = app.ActiveDoc;

var pgf = doc.TextSelection.beg.obj; // Paragraph at the insertion point.

var name = "CellHeading";

applyPgfFmt (pgf, name, doc);

function applyPgfFmt (pgf, name, doc) {

   

    var pgfFmt = 0;

   

    pgfFmt = doc.GetNamedPgfFmt (name);

    if (pgfFmt.ObjectValid ()) {

        var props = pgfFmt.GetProps ();

        pgf.SetProps(props);

    }

    else {

        pgf.Name = name;

     }

}

Votes

Translate

Translate

Report

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 Beginner ,
Sep 22, 2017 Sep 22, 2017

Copy link to clipboard

Copied

LATEST

Hi Rick,

Thanks for the reply.Sorry to say i know how to apply paragraph format, There is some reason that is why i didn't used paragraph format for this part of my coding. Even i need to convert my 2nd row content too. You can see in the below image that some cases its failing.

Please help me up on this.

With Regards

Aghil

Votes

Translate

Translate

Report

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