11 Replies Latest reply on Jul 22, 2017 9:42 PM by aghil2101

    HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?

    aghil2101

      Dear Experts,


      I have a Frame Maker document file which contain a imported Word file. The document contain lot of tables like below.

      What i am trying to do is to create a ExtendScript which will loop through whole tables in the Main Flow of Document and change the FONT Style and TEXT Size of content inside the table.

      FONT.PNG

      Please help me to sort out this issue.

       

      With Regards

      Aghil

        • 1. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
          4everJang Level 3

          Hello Aghil,

           

          I don't think you need a loop of any kind here. Try the following procedure manually before starting any scripting: Select File > Import > Formats, make sure the current document is selected in the list box at the top, unselect all options except the Paragraph Formats and make sure the checkboxes to override exceptions in the bottom are checked. Then run the import. If that cleans up the formatting in your tables, you can write a small script that does the import for you (if that is still required - it is a fairly simple action already).

           

          If this does not work, you may not have the cellbody and cellheading paragraph formats set up correctly. If all kinds of other things start changing in your documents, you should teach your authors to use formats and no overrides first. That is the start of any good content strategy: no exceptions anywhere anytime.

           

          Good luck

           

          Jang

          • 2. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
            aghil2101 Level 1

            Hi Jang,

             

            Thanks for the quick response. I will just brief you what i am doing.

            I am importing a word document to an FM Template. After importing i will delete everything except tables (already done using Extend Script). So now i am having 100 of tables in my document.

            The text size of the content inside the table is too small and font also has been changed. So i want to change the whole font type and text size of the text inside table.


            Sorry to say, i tried what you suggested but no change has happened . Since i am new to FM i didnt understand how exactly the import format option will help me in resizing the table text.

             

            With Regards

            Aghil

            • 3. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
              4everJang Level 3

              Hello Aghil,

               

              Try the following:

               

              1. Put the cursor in one of the table cells that has content (the too small text with incorrect font).

              2. Press Ctrl+m to open the Paragraph Designer

              3. In the Paragraph Designer, click on the button with the 'A' image on it - this shows the font properties page

              4. In the Paragraph Designer, change the font and font size

              5. In the bottom of the Paragraph Designer, press Update All

              6. If a dialog appears asking what to do with overrides, select Remove Overrides

              7. Keep making changes and pressing Apply All until you have the desired font and size

               

              If the table has headers which are still not OK, you will have to repeat this procedure for the table heading paragraph format.

               

              Once this is done, you can import the paragraph styles from this document into the FM Template that you are using. This may make the table cell styles appear correctly immediately when importing a Word document.

               

              Let us know if this solved your issue

               

              Jang

              1 person found this helpful
              • 4. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                aghil2101 Level 1

                Hi Jang,

                 

                That was really helpful. But how to import that particular style to other FM template. I tried as per your first instruction but no changes happened.

                 

                As of now what i did is.

                 

                1. Open a FM Document then imported word file into it.

                2. Run Extend Script to delete everything except tables.

                3. Place cursor on one cell goto Paragraph Designer then update the Font &Text size update all (Manually done)

                 

                So now i have a Paragraph Style. But to how import just this particular Paragraph style to another FM document Tables. So that all tables in the document gets updated.

                When i tried File - Import - Formats method it actually imported all formats and again i have to do STEP-3 manually.

                 

                 

                With Regards

                Aghil

                • 5. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                  4everJang Level 3

                  When you have the correct settings in a document (after importing the tables, cleaning up the document and setting the required styling for the table cvells), you save a copy of that document to become your new FM template. After saving it as a new document, clear all contents and save it again. Now you have an empty template to start with when you want to import Word materials.

                   

                  Now the method for getting the tables from Word into the required FM formats is:

                   

                  1. Open the FM template (the new one you just created - which has all the right styles in it)

                  2. Import the Word documents into this template

                  3. Run your extenscript to remove everything but the tables

                  4. If required, import paragraph styles from this document into itself while removing overrides

                   

                  That shoud do it.

                   

                  There might be an easier method, depending on how you import the Word documents into the FM template. Give more details about that and I can tell you if there is an easier and faster way of doing what you want to do.

                  • 6. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                    aghil2101 Level 1

                    Hi, Now by " File - Import - Format - Current - Import "  its updating the Font and Text Size.

                     

                    IMPORTING WORD FILE TO FM

                    1. File - Import - File - Select the Word File to import - Select Import By Reference - Import.

                    2. Unknown File Type - Microsoft Word 2007 - Convert.

                    3. In Import Text Flow by Reference - I kept all default values - Click Import.

                    4. Double Click on the Word Document - Convert - Selected Text Inset - Convert.

                    5. After this i will RUN the Extend Script to delete items.

                     

                    Note :

                    Is it possible to Automate the Importing Word File & Importing Format item using Extend Script.

                    • 7. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                      4everJang Level 3

                      As you are processing the imported content in FrameMaker, I would not import the Word content by reference (this keeps the link to the original document, so if you update the FM file the Word document will be imported again, overwriting the materials you have adapted.

                       

                      When importing by copying, you get a dialog with conversion settings (I am using FM2015 and I don't know whether this dialog appears in earlier releases)) that may allow skipping the whiole reformatting step. I know this kind of import can be scripted, but it is too much work to teach you that via this forum. Maybe some of the other experts can give you some code, but I need to make a living and spend time on paid projects instead. I trust you understand that.

                       

                      Try the approach I indicated above - they might solve a couple of problems in an easier way.

                       

                      Good luck

                      • 8. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                        frameexpert Level 4

                        If you want to change the font and style of the text of an entire paragraph, you should apply a paragraph format that has the desired formatting. Here is a function for doing that:

                         

                        function applyPgfFmt (pgf, name, doc) {
                           
                            var pgfFmt = 0;
                           
                            pgfFmt = doc.GetNamedPgfFmt (name);
                            if (pgfFmt.ObjectValid ()) {
                                var props = pgfFmt.GetProps ();
                                pgf.SetProps(props);
                            }
                            else {
                                $.writeln ("Paragraph format does not exist: " + name);
                                pgf.Name = name;
                            }
                        }
                        

                         

                        where pgf is the paragraph object, name is the paragraph format's name, and doc is the document object.

                        • 9. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                          frameexpert Level 4

                          I suggest that you break this down into tasks, starting with the smallest and moving to the largest.

                           

                          1) How do I apply changes the paragraph containing the insertion point?

                           

                          2) How do I loop through all of the paragraphs in the selected cell?

                           

                          3) How do I loop through all of the cells in the table?

                           

                          4) How do I loop through all of the tables in the document's main flow? (This is where your current script is broken.)

                           

                          As you test each task on a small level, you can be confident that it will work when you expand it to an entire table or document. Each task will be accomplished by one or more functions that you can chain together to form your finished script.

                           

                          As Jang mentioned, some of us on the forum do this kind of work as our regular jobs, so we have to give priority to our paying clients. However, we like to help others. But it is easier to get help for smaller tasks.

                           

                          That said, here is some code that will loop through all of the tables in the main flow of the document:

                           

                          var textList, i, tbl;
                          
                          // Get a list of all of the document's main flow tables.
                          textList = doc.MainFlowInDoc.GetText (Constants.FTI_TblAnchor);
                          for (i = 0; i < textList.length; i += 1) {
                              // Get the Tbl object for the current table.
                              tbl = textList[i].obj;
                              // Call a function here to process this table.
                          }   
                          
                          • 10. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                            aghil2101 Level 1

                            Hi jang,

                             

                            Ya that solved my problem. Thanks a lot for the help shown.

                            • 11. Re: HOW TO EDIT TEXT ITEMS INSIDE THE TABLE?
                              aghil2101 Level 1

                              Hi Rick,

                               

                              Thanks a lot for the reply. I understood your point very much. The problem is that i am not getting enough time to learn from the base due to the project pressure. But i will definitely follow the process what you explained. Will get back to you on this.

                               

                              With Regards

                              Aghil