7 Replies Latest reply on Oct 1, 2014 6:05 AM by Mnietek1

    haw to restore deleted master page object

    Mnietek1 Level 1

      If I apply Master Page to some page an then override and delete some object which originates on master page - is there any way to bring it back again with scripting?

      I'd like to avoid reapplying Master Page  - becuse I don't wat to reset overridden attributes other master page objects.

        • 1. Re: haw to restore deleted master page object
          Harbs. Level 6

          There's two ways you can go about it:


          1) You can compare the master page items to the page items and see which ones are missing. If an item is missing, you can duplicate it to the local page. It will not be overridden, so you will need to write a custom script label to track that it's a "virtual overridden" item.


          2) You can loop through all local page items, and find the overridden ones. Then you reapply the master page and re-override the page items and reapply any changes.


          Neither method is ideal, but I don't see another way to go about it.


          Good luck!


          • 2. Re: haw to restore deleted master page object
            Mnietek1 Level 1

            2) ... Then you reapply the master page and re-override the page items and reapply any changes.

            Thanks for your suggestions.

            Do you know an efficient way to store and later restore all properties / attributes / content of particular object?

            • 3. Re: Re: haw to restore deleted master page object
              Harbs. Level 6

              Most properties can be stored and applied using the "properties" property.


              Depending on the content type, you will need to handle it differently. FWIW, here's some code that will apply properties from one text frame to another. For content you would need to either move/copy the text or thread the frame.


              function applyProperties(origin,target){
                  target.properties = GetTextFrameProperties(origin)
                  target.textWrapPreferences.properties = origin.textWrapPreferences.properties;
              function GetTextFrameProperties(frame){
                  var frameProps = frame.properties;
                  var e;
                  //frame = frame.properties;
                  var properties = {}
                  for( var x in frameProps){
                      switch (x){
              //~        contentType:frame.contentType,
                          case "cornerRadius":properties.cornerRadius = frameProps.cornerRadius;break;
                          case "fillColor": properties.fillColor  = frameProps.fillColor;break;
                          case "fillTint": properties.fillTint = frameProps.fillTint;break;
                          case "gapColor": properties.gapColor = frameProps.gapColor;break;
                          case "gapTint": properties.gapTint = frameProps.gapTint;break;
                          case "horizontalScale": properties.horizontalScale = frameProps.horizontalScale;break;
                          case "itemLayer": properties.itemLayer = frameProps.itemLayer;break;
                          case "label": properties.label = frameProps.label;break;
                          case "rotationAngle": properties.rotationAngle = frameProps.rotationAngle;break;
                          case "shearAngle": properties.shearAngle = frameProps.shearAngle;break;
                          case "strokeAlignment": properties.strokeAlignment = frameProps.strokeAlignment;break;
                          case "strokeColor": properties.strokeColor = frameProps.strokeColor;break;
                          case "strokeTint": properties.strokeTint = frameProps.strokeTint;break;
                          case "strokeType": properties.strokeType = frameProps.strokeType;break;
                          case "strokeWeight": properties.strokeWeight = frameProps.strokeWeight;break;
                          //textWrapPreferences: properties.frameProps.
                          case "verticalScale": properties.verticalScale = frameProps.verticalScalebreak;
                          case "allowOverrides": properties.allowOverrides=frameProps.allowOverrides;break;
                          case "absoluteHorizontalScale": properties.absoluteHorizontalScale=frameProps.absoluteHorizontalScale;break;
                          case "absoluteRotationAngle": properties.absoluteRotationAngle=frameProps.absoluteRotationAngle;break;
                          case "absoluteShearAngle": properties.absoluteShearAngle=frameProps.absoluteShearAngle;break;
                          case "absoluteVerticalScale": properties.absoluteVerticalScale=frameProps.absoluteVerticalScale;break;
                          case "dataStore": properties.dataStore=frameProps.dataStore;break;
                          case "endCap": properties.endCap=frameProps.endCap;break;
                          case "endJoin": properties.endJoin=frameProps.endJoin;break;
                          case "gradientFillAngle": properties.gradientFillAngle=frameProps.gradientFillAngle;break;
                          case "gradientFillLength": properties.gradientFillLength=frameProps.gradientFillLength;break;
                          case "gradientFillStart": properties.gradientFillStart=frameProps.gradientFillStart;break;
                          case "gradientStrokeAngle": properties.gradientStrokeAngle=frameProps.gradientStrokeAngle;break;
                          case "gradientStrokeLength": properties.gradientStrokeLength=frameProps.gradientStrokeLength;break;
                          case "gradientStrokeStart": properties.gradientStrokeStart=frameProps.gradientStrokeStart;break;
                          case "javascript": properties.javascript=frameProps.javascript;break;
                          case "leftLineEnd": properties.leftLineEnd=frameProps.leftLineEnd;break;
                          case "localDisplaySetting": properties.localDisplaySetting=frameProps.localDisplaySetting;break;
                          case "miterLimit": properties.miterLimit=frameProps.miterLimit;break;
                          case "nonprinting": properties.nonprinting=frameProps.nonprinting;break;
                          case "overprintFill": properties.overprintFill=frameProps.overprintFill;break;
                          case "overprintGap": properties.overprintGap=frameProps.overprintGap;break;
                          case "overprintStroke": properties.overprintStroke=frameProps.overprintStroke;break;
                          case "rightLineEnd": properties.rightLineEnd=frameProps.rightLineEnd;break;
                          case "strokeCornerAdjustment": properties.strokeCornerAdjustment=frameProps.strokeCornerAdjustment;break;
                          case "strokeDashAndGap": properties.strokeDashAndGap=frameProps.strokeDashAndGap;break;
                          case "cornerEffect": properties.cornerEffect = frameProps.cornerEffect;break;
                          case "featherCornerType": properties.featherCornerType = frameProps.featherCornerType;break;
                          case "featherMode": properties.featherMode = frameProps.featherMode;break;
                          case "featherNoise": properties.featherNoise = frameProps.featherNoise;break;
                          case "featherWidth": properties.featherWidth = frameProps.featherWidth;break;
                          case "isolateBlending": properties.isolateBlending = frameProps.isolateBlending;break;
                          case "nonprinting": properties.nonprinting = frameProps.nonprinting;break;
                          case "opacity": properties.opacity = frameProps.opacity;break;
                          case "shadowOpacity": properties.shadowOpacity = frameProps.shadowOpacity;break;
                          case "shadowSpread": properties.shadowSpread = frameProps.shadowSpread;break;
                          case "shadowXOffset": properties.shadowXOffset = frameProps.shadowXOffset;break;
                          case "shadowYOffset": properties.shadowYOffset = frameProps.shadowYOffset;break;
                          case "cornerOption": properties.cornerOption = frameProps.cornerOption;break;
                          case "flip": properties.flip = frameProps.flip;break;
                          case "absoluteFlip": properties.absoluteFlip = frameProps.absoluteFlip;break;
                  return properties;



              • 4. Re: haw to restore deleted master page object
                Mnietek1 Level 1

                Thank you very much

                • 5. Re: haw to restore deleted master page object
                  Mnietek1 Level 1

                  One more thing - what is this line for (and whole function GetTextFrameProperties):

                  target.properties = GetTextFrameProperties(origin)

                  Why not just:

                  target.properties = origin.properties

                  Maybe stupid question....

                  • 6. Re: haw to restore deleted master page object
                    Harbs. Level 6

                    Truth be told, I don't remember. It's a very old function I have. There are probably some properties that cause problems when they are copied...

                    • 7. Re: haw to restore deleted master page object
                      Mnietek1 Level 1

                      Thanks for your answers.

                      Maybe one more:

                      Is there any way to copy contents of some frame to memory?

                      When I assign contents of graphic frame to some variable and then remove overrides from this frame - contents is lost...


                      sorry for my English