Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Color Change Problems

$
0
0

Hi All,

 

I am able to change some color definitions of a FM template file.
The first script I apply set successfully the "Color_OFF" mode as follows:

 

*     This script saves set a FM template file in Color_OFF mode.

*     The changes automatically made are :

*                                        Character Format

*                                            _Variable colour set to Black color

*                                            _Variable Corporate set to Black color

*                                        Colour Definition

*                                            'Blank Date' color composition set to 0% Cyan

*                                            'PDF_Bookmarks' color composition set to 100% Black

*                                            'Table' color composition set to 100% Black

*                                            'Table:1' color composition set to 100% Black

*                                            'Table:1_' color composition set to 100% Black

*                                            'Table:A' color composition set to 100% Black

*                                            'Table::a' color composition set to 100% Black

*                                            'Table:(1)' color composition set to 100% Black

*                                            'Table:(a)' color composition set to 100% Black

*    

****************************************************************************************** ********************************************/

// Set variables

var charfmtcol = new Array('_Variable colour', '_Variable Corporate');

var col = new Array('Blank Date', 'PDF_Bookmarks', 'Table', 'Table:1', 'Table:1_', 'Table:A', 'Table:a_', 'Table:(1)', 'Table:(a)');

var colorb = "Black";

 

// Get the active document.

var doc = app.ActiveDoc;

var colorb = doc.GetNamedColor(colorb);

 

// Check if FM template document is active

if (doc.ObjectValid() == true)

    {

        var i = 0;

        while (i < 2)

            // Change color of a character catalog type

            {

                var charfmt = doc.GetNamedCharFmt(charfmtcol[i]);

                if (charfmt.ObjectValid() == true)

                    {

                        charfmt.Color = colorb;

                        doc.SimpleImportFormats (doc, Constants.FF_UFF_FONT | Constants.FF_UFF_REMOVE_EXCEPTIONS);

                    }

                i++;

            }

        i = 0;

        while (i<10)

            {

                // Change a color definition

                var colorfmt = doc.GetNamedColor(col[i]);

                if (colorfmt.ObjectValid() == true)

                    {

                        if (i == 0)

                            {

                                colorfmt.Cyan = 0;

                            }   

                        else

                            {

                                colorfmt.Black = 6553600;

                            }

                        doc.SimpleImportFormats (doc, Constants.FF_UFF_COLOR);

                    }

                i++;

            }

     alert ("Script execution is completed!\nColor_OFF mode is now applied.", "Set-Color-OFF_in-Template");

    }

To reverse these color settings, I have tried unsuccessfully to execute the second script below :

                                    

*     This script saves set a FM template file in Color_ON mode.

*     The changes automatically made are :

*                                        Character Format

*                                            _Variable colour set to Red

*                                            _Variable Meggitt set to Magenta

*                                        Colour Definition

*                                            'Blank Date' color composition set to 100% Cyan

*                                            'PDF_Bookmarks' color composition set to 0% Black

*                                            'Table' color composition set to 0% Black

*                                            'Table:1' color composition set to 0% Black

*                                            'Table:1_' color composition set to 0% Black

*                                            'Table:A' color composition set to 0% Black

*                                            'Table::a' color composition set to 0% Black

*                                            'Table:(1)' color composition set to 0% Black

*                                            'Table:(a)' color composition set to 0% Black

*    

****************************************************************************************** ********************************************/

// Set variables

var charfmtcol = new Array ('_Variable colour', '_Variable Meggitt');

var color = new Array ('Red', 'Magenta');

var col = new Array ('Blank Date', 'PDF_Bookmarks', 'Table', 'Table:1', 'Table:1_', 'Table:A', 'Table:a_', 'Table:(1)', 'Table:(a)');

 

// Get the active document.

var doc = app.ActiveDoc;

 

// Check if FM template document is active

if (doc.ObjectValid() == true)

    {

        var i = 0;

        while (i < 2)

            // Change color of a character catalog type

            {

                var charfmt = doc.GetNamedCharFmt(charfmtcol[i]);

                if (charfmt.ObjectValid() == true)

                    {

                        charfmt.Color = color[i];

                        doc.SimpleImportFormats (doc, Constants.FF_UFF_FONT | Constants.FF_UFF_REMOVE_EXCEPTIONS);

                        alert("i = " + i + "\ncharfmtcol = " + charfmtcol[i] + "\ncharfmt.Color = " + charfmt.Color);

                    }

                i++;

            }

        i = 0;

        while (i<10)

            {

                // Change a color definition

                var colorfmt = doc.GetNamedColor(col[i]);

                if (colorfmt.ObjectValid() == true)

                    {

                        if (i == 0)

                            {

                                colorfmt.Cyan = 6553600;

                            }   

                        else

                            {

                                colorfmt.Black = 0;

                            }

                        doc.SimpleImportFormats (doc, Constants.FF_UFF_COLOR);

                    }

                i++;

            }

     alert ("Script execution is completed!\nColor_ON mode is now applied.", "Set-Color-ON_in-Template");

    }

Do you have any idea why the second script cannot set back the color parameters to their original settings?

Thanks.

 

JM


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>