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

Keeping this text box unaltered after save?

Advisor ,
Jan 29, 2019 Jan 29, 2019

This is kind of a continuation of my question from yesterday. I have a script that creates a box at the bottom of my page when i origionally made it and had it altered it overwrote the existing text box in that area. I did this on accident. How can i make it place the box there and if the file already has it there leave it alone. We type info in it and i dont want it over written every time.

  function addTextFramen(doc, layer, name){
        var mynBlendingSettings = { blendMode : BlendMode.OVERLAY };      
        var mynTransparencySettings = { blendingSettings : mynBlendingSettings };   
            
        var tfn = doc.textFrames.itemByName(name);
        if(tfn && tfn.isValid) {      
            tfn.remove
          
            ();
        }
        var orignUnit = app.scriptPreferences.measurementUnit;     
        app.scriptPreferences.measurementUnit = MeasurementUnits.INCHES;   
        tfn = doc.textFrames.add(layer, LocationOptions.UNKNOWN, {name: name, fillColor :"Magenta", fillTint: 40, transparencySettings : mynTransparencySettings}); 
        tfn.geometricBounds = [doc.pages[0].bounds[2] + .5, 5, doc.pages[0].bounds[2] + 1.55, 8.5] 
        app.scriptPreferences.measurementUnit = orignUnit;    
        return tfn; 
      
    }  
function doTfnOne(event){ 
      
    var doc = event.target;
    if(!(doc && doc.constructor.name == "Document")) { 
        return; 
   
      
    var myLayern = addLayer(doc, "SaveInfo"); 

    var tfn = addTextFramen(doc, myLayern, "NoteInfo");
  

    }  
 
TOPICS
Scripting
417
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 , Jan 30, 2019 Jan 30, 2019

Hi,

I am not clear on what is needed but i see in your code in the addTextFrame method you check if a textframe with the name exists or not and if it exists you remove it and then again add a new textframe. If you don't want to remove the old one you could comment out the remove method call and exit out of the code in this condition. I may be understanding something wrong if this is not what you want, please explain a bit more on what is wrong with the code you posted.

If you want to prevent accid

...
Translate
Community Expert ,
Jan 30, 2019 Jan 30, 2019

Hi,

I am not clear on what is needed but i see in your code in the addTextFrame method you check if a textframe with the name exists or not and if it exists you remove it and then again add a new textframe. If you don't want to remove the old one you could comment out the remove method call and exit out of the code in this condition. I may be understanding something wrong if this is not what you want, please explain a bit more on what is wrong with the code you posted.

If you want to prevent accidental moving of this box you could also explore locking the layer on which you are creating it.

-Manan

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
Advisor ,
Jan 30, 2019 Jan 30, 2019
LATEST

You answered it. thank you. I had to change the Remove to exit. I totally missed that it said .remove on on line 18. Thanks again.

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